[mirrorbrain-commits] [opensuse-svn] r6328 - trunk/tools/download-redirector-v2/mirrordoctor/mb

From: Novell Forge SVN <noreply_at_novell.com>
Date: Tue, 3 Feb 2009 02:04:05 -0700 (MST)
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)
@@ -1,4 +1,5 @@
 
+import sys
 from sqlobject import *
 
 
@@ -75,11 +76,23 @@
 
 class Conn:
     def __init__(self, config, debug = False):
-        uri_str = 'mysql://%s:%s@%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@%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.org
Received on 2009-02-03Z09:04:30

This archive was generated by hypermail 2.2.0 : 2009-07-10Z19:18:10 GMT