Author: poeml Date: 2009-02-03 02:03:55 -0700 (Tue, 03 Feb 2009) New Revision: 6328 Modified: trunk/tools/download-redirector-v2/mirrordoctor/mb/conn.py Log: mirrordoctor: remove MySQL as hardcoded database driver, and allow PostgreSQL Modified: trunk/tools/download-redirector-v2/mirrordoctor/mb/conn.py =================================================================== --- trunk/tools/download-redirector-v2/mirrordoctor/mb/conn.py 2009-02-03 00:59:36 UTC (rev 6327) +++ trunk/tools/download-redirector-v2/mirrordoctor/mb/conn.py 2009-02-03 09:03:55 UTC (rev 6328) _at_@ -1,4 +1,5 @@ +import sys from sqlobject import * _at_@ -75,11 +76,23 @@ class Conn: def __init__(self, config, debug = False): - uri_str = 'mysql://%s:%s_at_%s:%s/%s' + dbdriver = config.get('dbdriver', 'mysql') + if dbdriver in ['Pg', 'postgres', 'postgresql']: + dbdriver, dbport = 'postgres', '5432' + try: + import psycopg2 + except: + sys.exit('To use mb with PostgreSQL, you need the pcycopg2 Python module installed.') + elif dbdriver in ['mysql']: + dbport = '3306' + else: + sys.exit('database driver %r not known' % dbdriver) + + uri_str = dbdriver + '://%s:%s_at_%s:%s/%s' #if options.loglevel == 'DEBUG': # uri_str += '?debug=1' self.uri = uri_str % (config['dbuser'], config['dbpass'], - config['dbhost'], config.get('dbport', '3306'), + config['dbhost'], config.get('dbport', dbport), config['dbname']) sqlhub.processConnection = connectionForURI(self.uri) _______________________________________________ Opensuse-svn mailing list Opensuse-svn_at_forge.novell.com http://forge.novell.com/mailman/listinfo/opensuse-svn _______________________________________________ mirrorbrain-commits mailing list Note: To remove yourself from this list, send a mail with the content unsubscribe to the address mirrorbrain-commits-request_at_mirrorbrain.orgReceived on Tue Feb 03 2009 - 09:04:30 GMT
This archive was generated by hypermail 2.3.0 : Thu Mar 25 2010 - 19:29:04 GMT