Mercurial > p > roundup > code
diff roundup/backends/back_postgresql.py @ 2634:f47ca4541770
Both RDBMS backends now use the same config.ini section, [rdbms].
Comments on each option clearly state that the options only apply to
postgresql or mysql.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 27 Jul 2004 01:18:25 +0000 |
| parents | a9e1fff1e793 |
| children | 921780161fb9 |
line wrap: on
line diff
--- a/roundup/backends/back_postgresql.py Tue Jul 27 00:57:19 2004 +0000 +++ b/roundup/backends/back_postgresql.py Tue Jul 27 01:18:25 2004 +0000 @@ -14,37 +14,15 @@ from roundup import hyperdb, date from roundup.backends import rdbms_common -from roundup import configuration - -configuration.SETTINGS += ( - ("postgresql", ( - (configuration.Option, 'database', 'roundup'), - (configuration.NullableOption, 'host', 'localhost'), - (configuration.NullableOption, 'port', '5432'), - (configuration.NullableOption, 'user', 'roundup'), - (configuration.NullableOption, 'password', 'roundup'), - )), -) - -def connection_dict(config): - d = { - 'database': config.POSTGRESQL_DATABASE, - } - for name in 'host', 'port', 'password', 'user': - cvar = 'POSTGRESQL_'+name.upper() - if config[cvar] is not None: - d[name] = config[cvar] - return d - def db_create(config): """Clear all database contents and drop database itself""" - command = 'CREATE DATABASE %s'%config.POSTGRESQL_DATABASE + command = 'CREATE DATABASE %s'%config.RDBMS_NAME config.logging.getLogger('hyperdb').info(command) db_command(config, command) def db_nuke(config, fail_ok=0): """Clear all database contents and drop database itself""" - command = 'DROP DATABASE %s'% config.POSTGRESQL_DATABASE + command = 'DROP DATABASE %s'% config.RDBMS_NAME config.logging.getLogger('hyperdb').info(command) db_command(config, command) @@ -55,7 +33,7 @@ '''Perform some sort of database-level command. Retry 10 times if we fail by conflicting with another user. ''' - template1 = connection_dict(config) + template1 = rdbms_common.connection_dict(config) template1['database'] = 'template1' try: @@ -92,7 +70,7 @@ def db_exists(config): """Check if database already exists""" - db = connection_dict(config) + db = rdbms_common.connection_dict(config, 'database') try: conn = psycopg.connect(**db) conn.close() @@ -104,8 +82,9 @@ arg = '%s' def sql_open_connection(self): - db = connection_dict(config) - self.config.logging.getLogger('hyperdb').info('open database %r'%db) + db = rdbms_common.connection_dict(config, 'database') + self.config.logging.getLogger('hyperdb').info('open database %r'%( + db['database'],)) try: conn = psycopg.connect(**db) except psycopg.OperationalError, message:
