[Zope-CVS] CVS: Products/Ape/lib/apelib/sql - dbapi.py:1.6

Shane Hathaway shane at zope.com
Fri Mar 19 23:24:30 EST 2004


Update of /cvs-repository/Products/Ape/lib/apelib/sql
In directory cvs.zope.org:/tmp/cvs-serv30121/lib/apelib/sql

Modified Files:
	dbapi.py 
Log Message:
Finished MySQL connectivity


=== Products/Ape/lib/apelib/sql/dbapi.py 1.5 => 1.6 ===
--- Products/Ape/lib/apelib/sql/dbapi.py:1.5	Thu Mar 11 00:58:38 2004
+++ Products/Ape/lib/apelib/sql/dbapi.py	Fri Mar 19 23:24:29 2004
@@ -379,7 +379,7 @@
 
         type_name is 'table' or 'sequence'
         """
-        name = self.prefix + name
+        table_name = self.prefix + name
         if type_name == 'table':
             sql = ('SELECT tablename FROM pg_tables '
                    'WHERE tablename = :name')
@@ -388,7 +388,7 @@
                    "WHERE relkind = 'S' and relname = :name")
         else:
             raise ValueError(type_name)
-        rows = self.execute(sql, {'name': name}, fetch=1)
+        rows = self.execute(sql, {'name': table_name}, fetch=1)
         return len(rows)
 
     def createSequence(self, name, start=1):
@@ -430,25 +430,19 @@
 
         type_name is 'table' or 'sequence'
         """
-        # XXX TODO
-        name = self.prefix + name
-        if type_name == 'table':
-            sql = ('SELECT tablename FROM pg_tables '
-                   'WHERE tablename = :name')
-        elif type_name == 'sequence':
-            sql = ("SELECT relname FROM pg_class "
-                   "WHERE relkind = 'S' and relname = :name")
-        else:
+        table_name = self.prefix + name
+        if type_name not in ('table', 'sequence'):
             raise ValueError(type_name)
-        rows = self.execute(sql, {'name': name}, fetch=1)
+        sql = 'SHOW TABLES LIKE :name'
+        rows = self.execute(sql, {'name': table_name}, fetch=1)
         return len(rows)
 
     def createSequence(self, name, start=1):
         """Creates a sequence.
         """
         table_name = self.prefix + name
-        self.execute("CREATE TABLE %s (last_value int)" % self.table_name)
-        self.execute("INSERT INTO %s VALUES (%d)" % (self.table_name, start))
+        self.execute("CREATE TABLE %s (last_value int)" % table_name)
+        self.execute("INSERT INTO %s VALUES (%d)" % (table_name, start))
 
     def resetSequence(self, name, start=1):
         """Resets a sequence.




More information about the Zope-CVS mailing list