changeset 447:0b71da565ebe

added gerald patches
author catherine@dellzilla
date Wed, 10 Feb 2010 13:30:23 -0500
parents 1cf1f69b2470
children 9708afb3bb41
files oracle_schema.patch schema.patch sqlpython/connections.py
diffstat 3 files changed, 34 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/oracle_schema.patch	Wed Feb 10 13:30:23 2010 -0500
@@ -0,0 +1,7 @@
+171c171,174
+<             schema[table_key] = Table(table_name, cursor, owner)
+---
+>             try:
+>                 schema[table_key] = Table(table_name, cursor, owner)
+>             except Exception, e:
+>                 LOG.warning('Failed to get metadata for table %s.%s: %s' % (owner, table_name, str(e)))                
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/schema.patch	Wed Feb 10 13:30:23 2010 -0500
@@ -0,0 +1,13 @@
+94c94,98
+<             # Connect to the db and suck out the data dictionary information
+---
+>             # Connect to the db and suck out the data dictionary information            
+>             self.connect(connection_string)
+>             self.schema = self._get_schema(self._cursor)
+> 
+>     def connect(self, connection_string):
+99,100c103
+<             self.schema = self._get_schema(self._cursor)
+< 
+---
+>             
--- a/sqlpython/connections.py	Tue Feb 09 21:16:16 2010 -0500
+++ b/sqlpython/connections.py	Wed Feb 10 13:30:23 2010 -0500
@@ -7,6 +7,7 @@
 import pickle
 import optparse
 import doctest
+import benchmark
 
 try:
     import cx_Oracle
@@ -91,6 +92,9 @@
         >>> opts = OptionTestDummy(mysql=True, password='password')
         >>> ConnectionData('thedatabase theuser', opts).uri()        
         'mysql://theuser:password@localhost:3306/thedatabase'
+        >>> opts = OptionTestDummy(mysql=True, password='password')
+        >>> ConnectionData('thedatabase', opts).uri()        
+        'mysql://catherine:password@localhost:3306/thedatabase'
         '''
         self.arg = arg
         self.opts = opts
@@ -149,6 +153,7 @@
     def set_defaults(self):
         self.port = self.default_port       
         self.hostname = 'localhost'
+        self.username = os.getenv('USER')
         self.database = os.getenv('USER')
     def connection(self):
         return MySQLdb.connect(host = self.hostname, user = self.username, 
@@ -245,9 +250,10 @@
         return os.path.join(self.pickledir, ('%s.%s.%s.%s.pickle' % 
                              (self.rdbms, self.username, self.conn_data.hostname, self.database)).lower())
     def retreive_pickled_gerald(self):
-        picklefile = open(self.picklefile())
-        schema = pickle.load(picklefile)
-        picklefile.close()
+        with benchmark.benchmark('gerald retrieve'):
+            picklefile = open(self.picklefile())
+            schema = pickle.load(picklefile)
+            picklefile.close()
         newgerald = gerald_classes[self.rdbms](self.username, None)
         newgerald.connect(self.conn_data.gerald_uri())
         newgerald.schema = schema  
@@ -269,10 +275,12 @@
             except IOError:
                 pass
         self.db_instance.gerald.current = False
-        newgerald = gerald_classes[self.db_instance.rdbms](self.db_instance.username, self.db_instance.conn_data.gerald_uri())
+        with benchmark.benchmark('metadata gather'):
+            newgerald = gerald_classes[self.db_instance.rdbms](self.db_instance.username, self.db_instance.conn_data.gerald_uri())
         newgerald.descriptions = {}
-        for (name, obj) in newgerald.schema.items():
-            newgerald.descriptions[name] = ObjectDescriptor(name, obj)            
+        with benchmark.benchmark('fill out descriptions'):
+            for (name, obj) in newgerald.schema.items():
+                newgerald.descriptions[name] = ObjectDescriptor(name, obj)            
         newgerald.current = True
         newgerald.complete = True
         self.db_instance.gerald = newgerald