commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r9452 - in trunk/gnue-common/src/datasources: . drivers/sql/oracl


From: jan
Subject: [gnue] r9452 - in trunk/gnue-common/src/datasources: . drivers/sql/oracle
Date: Thu, 29 Mar 2007 10:02:52 -0500 (CDT)

Author: jan
Date: 2007-03-29 10:02:51 -0500 (Thu, 29 Mar 2007)
New Revision: 9452

Modified:
   trunk/gnue-common/src/datasources/drivers/sql/oracle/Base.py
   trunk/gnue-common/src/datasources/drivers/sql/oracle/Behavior.py
   trunk/gnue-common/src/datasources/readgsd.py
Log:
fix oracle introspection (tables+fields)
fix gnue-schema data only mode


Modified: trunk/gnue-common/src/datasources/drivers/sql/oracle/Base.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/sql/oracle/Base.py        
2007-03-28 12:17:10 UTC (rev 9451)
+++ trunk/gnue-common/src/datasources/drivers/sql/oracle/Base.py        
2007-03-29 15:02:51 UTC (rev 9452)
@@ -30,6 +30,7 @@
 __noplugin__ = True
 
 import os
+from gnue.common.apps import errors
 
 from gnue.common.datasources.drivers import DBSIG2
 from gnue.common.datasources.drivers.sql.oracle import Behavior
@@ -61,6 +62,8 @@
 
     if parameters.has_key ('oracle_home'):
       os.environ ['ORACLE_HOME'] = parameters ['oracle_home']
+    elif not os.environ.has_key("ORACLE_HOME"):
+      raise errors.AdminError('Environment parameter "ORACLE_HOME" is not 
defined!')
 
 
   # ---------------------------------------------------------------------------

Modified: trunk/gnue-common/src/datasources/drivers/sql/oracle/Behavior.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/sql/oracle/Behavior.py    
2007-03-28 12:17:10 UTC (rev 9451)
+++ trunk/gnue-common/src/datasources/drivers/sql/oracle/Behavior.py    
2007-03-29 15:02:51 UTC (rev 9452)
@@ -28,6 +28,7 @@
 from gnue.common.datasources import GSchema
 from gnue.common.datasources.drivers import DBSIG2
 
+import string
 
 # =============================================================================
 # Behavior class
@@ -84,23 +85,27 @@
   # ---------------------------------------------------------------------------
 
   def __readTables (self, parent):
-    
+
     masters = {}
     result  = {}
 
+    where_type = self.__RELKIND.keys()
+
+    # TODO: exclude system tables to increase performance
     cmd = \
       "select owner||'.'||table_name||'.'||table_type full_name, \n" + \
       "  decode(owner,user,null,owner||'.')||table_name table_name, \n" + \
       "  decode(owner,user,'user_','all_')||lower(table_type) table_type \n" + 
\
-      "  from all_catalog where table_type in ('%s') %s \n" \
-              % (string.join(where_type,"','"), where_user) + \
+      "  from all_catalog \n" + \
+      "  where decode(owner,user,'user_','all_')||lower(table_type) in ('%s') 
\n" \
+              % string.join(where_type,"','") + \
       "  order by table_name "
 
-    cursor = self.__connection.makecursor ()
+    cursor = self.__connection.makecursor (cmd)
     try:
       for (fullname, name, kind) in cursor.fetchall ():
         if not kind in masters:
-          masters [kind] = GSchema.GSTables (self.__RELKIND [kind])
+          masters [kind] = GSchema.GSTables (parent, **self.__RELKIND [kind])
 
         properties = {'id': fullname, 'name': name.lower (), 'kind': kind}
         result [fullname] = GSchema.GSTable (masters [kind], **properties)
@@ -116,7 +121,7 @@
   # ---------------------------------------------------------------------------
 
   def __readFields (self, tables):
-    
+
     for (key, table) in tables.items ():
 
       (owner, name, type) = key.split ('.')
@@ -157,9 +162,11 @@
                    'nullable'  : nullable != 'N'}
 
           if nativetype == 'NUMBER':
-            attrs ['precision'] = int (scale)
+            attrs ['precision'] = int (scale or 0)
             attrs ['type']      = 'number'
-            attrs ['length']    = int (prec)
+            attrs ['length']    = int (prec or 38)
+            # 38 is the default decimal precision according to
+            # Oracle(c) Database SQL Reference 10g Release 2 (10.2)
 
           elif nativetype == 'DATE':
             attrs ['type'] = 'date'
@@ -169,8 +176,8 @@
             if int (length):
               attrs ['length'] = int (length)
 
-        parent = table.findChildOfType ('GSFields') or GSchema.GSFields (table)
-        GSchema.GSField (parent, **attrs)
+          parent = table.findChildOfType ('GSFields') or GSchema.GSFields 
(table)
+          GSchema.GSField (parent, **attrs)
 
       finally:
         cursor.close ()
@@ -260,7 +267,7 @@
 
     length = hasattr (field, 'length') and field.length or 99999
     if length <= 2000:
-      return "varchar2 (%s) % length"
+      return "varchar2 (%s)" % length
     else:
       return "blob"
 

Modified: trunk/gnue-common/src/datasources/readgsd.py
===================================================================
--- trunk/gnue-common/src/datasources/readgsd.py        2007-03-28 12:17:10 UTC 
(rev 9451)
+++ trunk/gnue-common/src/datasources/readgsd.py        2007-03-29 15:02:51 UTC 
(rev 9452)
@@ -121,8 +121,8 @@
     Client application for reading and importing gsd files.
     """
 
-    NAME    = "readgsd"
-    COMMAND = "readgsd"
+    NAME    = "gnue-schema"
+    COMMAND = "gnue-schema"
     VERSION = "0.1.0"
     USAGE   = "%s file [, file, ...]" % GClientApp.GClientApp.USAGE
     SUMMARY = u_("Import GNUe Schema Definition files into a given connection")
@@ -349,6 +349,10 @@
 
     def __import_data(self):
 
+        # remember to login if not updating schema
+        if not self.__do_schema:
+            self.connections.loginToConnection(self.connection)
+
         print o(u_("Updating data ..."))
 
         # First fetch the current schema from the backend





reply via email to

[Prev in Thread] Current Thread [Next in Thread]