changeset 494:ff3470e79ac2

fixing uri connect problems
author Catherine Devlin <catherine.devlin@gmail.com>
date Tue, 14 Sep 2010 05:28:57 -0400
parents 30e314597285
children 490ede56f348
files sqlpython/connections.py sqlpython/pgSession.txt
diffstat 2 files changed, 6 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/sqlpython/connections.py	Wed Sep 08 11:28:24 2010 -0400
+++ b/sqlpython/connections.py	Tue Sep 14 05:28:57 2010 -0400
@@ -112,7 +112,7 @@
         self.arg = arg
         self.opts = opts
         self.default_rdbms = default_rdbms
-        self.determine_rdbms()
+        self.determine_rdbms()  # may be altered later as connect string is parsed
         if not self.parse_connect_uri(arg):
             self.set_defaults()        
             connectargs = self.connection_parser.search(self.arg)
@@ -133,12 +133,13 @@
     def parse_connect_uri(self, uri):
         results = self.connection_uri_parser.search(uri)
         if results:
+            self.set_class_from_rdbms_name(results.group('rdbms'))     
             r = gerald.utilities.dburi.Connection().parse_uri(results.group('connect_string'))
             self.username = r.get('user') or self.username
             self.password = r.get('password') or self.password
             self.hostname = r.get('host') or self.hostname
-            self.set_class_from_rdbms_name(results.group('rdbms'))
-            self.port = self.port or self.default_port        
+            self.port = self.port or self.default_port
+            self.database = r.get('db_name')
             return True
         else:
             return False
@@ -150,9 +151,9 @@
         return '%s://%s:%s@%s:%s/%s' % (self.rdbms, self.username, self.password,
                                          self.hostname, self.port, self.database)  
     def determine_rdbms(self):
-        if self.opts.mysql:
+        if self.opts.mysql or self.arg.startswith('mysql://'):
             self.__class__ = MySQLInstance
-        elif self.opts.postgres:
+        elif self.opts.postgres or self.arg.startswith('postgres://') or self.arg.startswith('postgresql://'):
             self.__class__ = PostgresInstance
         else:
             self.set_class_from_rdbms_name(self.default_rdbms)     
--- a/sqlpython/pgSession.txt	Wed Sep 08 11:28:24 2010 -0400
+++ b/sqlpython/pgSession.txt	Tue Sep 14 05:28:57 2010 -0400
@@ -65,8 +65,6 @@
 
 5 rows selected.
 
-0:testuser@testplatform> refresh
-0:testuser@testplatform> py import time; time.sleep(120) # allow metadata to load
 0:testuser@testplatform> ls
 table/play
 0:testuser@testplatform> ls -l