[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
r5928 - in trunk/gnue-common/src/datasources: . drivers/interbase/Schema
From: |
johannes |
Subject: |
r5928 - in trunk/gnue-common/src/datasources: . drivers/interbase/Schema/Creation |
Date: |
Wed, 7 Jul 2004 17:14:08 -0500 (CDT) |
Author: johannes
Date: 2004-06-23 06:58:56 -0500 (Wed, 23 Jun 2004)
New Revision: 5928
Modified:
trunk/gnue-common/src/datasources/GLoginHandler.py
trunk/gnue-common/src/datasources/drivers/interbase/Schema/Creation/Creation.py
Log:
Implemented createDatabase () for interbase driver
Modified: trunk/gnue-common/src/datasources/GLoginHandler.py
===================================================================
--- trunk/gnue-common/src/datasources/GLoginHandler.py 2004-06-22 19:23:34 UTC
(rev 5927)
+++ trunk/gnue-common/src/datasources/GLoginHandler.py 2004-06-23 11:58:56 UTC
(rev 5928)
@@ -91,7 +91,7 @@
print "*"*60
return val
except KeyboardInterrupt:
- raise GLoginHandler.UserCanceledLogin
+ raise UserCanceledLogin
def destroyLoginDialog(self):
Modified:
trunk/gnue-common/src/datasources/drivers/interbase/Schema/Creation/Creation.py
===================================================================
---
trunk/gnue-common/src/datasources/drivers/interbase/Schema/Creation/Creation.py
2004-06-22 19:23:34 UTC (rev 5927)
+++
trunk/gnue-common/src/datasources/drivers/interbase/Schema/Creation/Creation.py
2004-06-23 11:58:56 UTC (rev 5928)
@@ -21,20 +21,12 @@
# $Id$
import os
+from gnue.common.datasources.GLoginHandler import BasicLoginHandler
from gnue.common.datasources.drivers.DBSIG2.Schema.Creation import \
Creation as Base
# =============================================================================
-# Exceptions
-# =============================================================================
-
-class NoBinaryError (gException):
- def __init__ (self):
- gException.__init__ (self, u_("No binary for isql(-fb) provided."))
-
-
-# =============================================================================
# Class implementing schema creation for Interbase (5.x/6.x), Firebird (1.x)
# =============================================================================
@@ -47,38 +39,48 @@
# Create a new database
# ---------------------------------------------------------------------------
- def __hack__createDatabase (self):
+ def createDatabase (self):
"""
- This function is not yet activated, but should somedays create a database
- as described by the connection.
+ This function creates a new database as specified by the given connection's
+ parameters. The password for the SYSDBA will be queried.
"""
dbname = self.connection.parameters.get ('dbname', None)
username = self.connection.parameters.get ('username', 'gnue')
password = self.connection.parameters.get ('password', None)
host = self.connection.parameters.get ('host', None)
- isqlbin = self.connection.parameters.get ('isqlbin', None)
+ gsecbin = self.connection.parameters.get ('gsecbin', 'gsec')
- if not isqlbin:
- raise NoBinaryError
+ res = {'_password': ''}
+ while not res ['_password']:
+ res = BasicLoginHandler ().getLogin (['as SYSDBA', 'Security Database',
+ [['_password', 'Password', True]]], '')
+ syspw = res ['_password']
if host:
dburl = "%s:%s" % (host, dbname)
else:
dburl = dbname
- code = open ("ib.sql", "w")
+ code = u"%s -user sysdba -password %s -delete %s" % \
+ (gsecbin, syspw, username)
+
try:
- code.write (u"CREATE DATABASE '%s' USER 'sysdba' PASSWORD 'masterkey' "
- "DEFAULT CHARACTER SET UTF8;\n" % dburl)
- code.close ()
+ os.system (code)
+ except:
+ pass
- if os.system (u"%s -i ib.sql" % isqlbin):
- raise gException, ("Cannot create database")
+ code = u"%s -user sysdba -password %s -add %s" % (gsecbin, syspw, username)
+ if password:
+ code += " -pw %s" % password
- finally:
- os.unlink ("ib.sql")
+ if os.system (code):
+ raise gException, ("Cannot create user")
+ self.connection._driver.create_database (\
+ u"create database '%s' user '%s' password '%s'"
+ % (dburl, username, password))
+
# ---------------------------------------------------------------------------
# Process a defaultwith attribute
# ---------------------------------------------------------------------------
@@ -130,12 +132,12 @@
"""
if fieldDefinition.has_key ('length') and \
- fieldDefinition ['length'] <= 32767:
+ fieldDefinition ['length'] <= 32000:
return "varchar (%s)" % fieldDefinition ['length']
elif not fieldDefinition.has_key ('length'):
- return "varchar (32767)"
+ return "varchar (32000)"
else:
return "blob"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- r5928 - in trunk/gnue-common/src/datasources: . drivers/interbase/Schema/Creation,
johannes <=