--- a/server/serverctl.py Tue Dec 22 19:27:51 2009 +0100
+++ b/server/serverctl.py Wed Dec 23 12:20:10 2009 +0100
@@ -55,8 +55,11 @@
password = source['db-password']
else:
password = getpass('password: ')
+ extra_args = source.get('db-extra-arguments')
+ extra = extra_args and {'extra_args': extra_args} or {}
return get_connection(driver, dbhost, dbname, user, password=password,
- port=source.get('db-port'))
+ port=source.get('db-port'),
+ **extra)
def system_source_cnx(source, dbms_system_base=False,
special_privs='CREATE/DROP DATABASE', verbose=True):
@@ -281,11 +284,16 @@
automatic = self.get('automatic')
appid = pop_arg(args, msg='No instance specified !')
config = ServerConfiguration.config_for(appid)
- create_db = self.config.create_db
source = config.sources()['system']
+ dbname = source['db-name']
driver = source['db-driver']
+ create_db = self.config.create_db
helper = get_adv_func_helper(driver)
- if create_db:
+ if driver == 'sqlite':
+ if os.path.exists(dbname) and automatic or \
+ ASK.confirm('Database %s already exists -- do you want to drop it ?' % dbname):
+ os.unlink(dbname)
+ elif create_db:
print '\n'+underline_title('Creating the system database')
# connect on the dbms system base to create our base
dbcnx = _db_sys_cnx(source, 'CREATE DATABASE and / or USER', verbose=verbose)
@@ -297,7 +305,6 @@
ASK.confirm('Create db user %s ?' % user, default_is_yes=False)):
helper.create_user(source['db-user'], source['db-password'])
print '-> user %s created.' % user
- dbname = source['db-name']
if dbname in helper.list_databases(cursor):
if automatic or ASK.confirm('Database %s already exists -- do you want to drop it ?' % dbname):
cursor.execute('DROP DATABASE %s' % dbname)
@@ -310,7 +317,7 @@
helper.create_database(cursor, dbname,
encoding=source['db-encoding'])
dbcnx.commit()
- print '-> database %s created.' % source['db-name']
+ print '-> database %s created.' % dbname
except:
dbcnx.rollback()
raise
@@ -364,10 +371,13 @@
config = ServerConfiguration.config_for(appid)
try:
system = config.sources()['system']
+ extra_args=system.get('db-extra-arguments')
+ extra = extra_args and {'extra_args': extra_args} or {}
get_connection(
system['db-driver'], database=system['db-name'],
host=system.get('db-host'), port=system.get('db-port'),
- user=system.get('db-user'), password=system.get('db-password'))
+ user=system.get('db-user'), password=system.get('db-password'),
+ **extra)
except Exception, ex:
raise ConfigurationError(
'You seem to have provided wrong connection information in '\