dabo Commit
Revision 3331
Date: 2007-08-23 18:19:29 -0700 (Thu, 23 Aug 2007)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/3331
Changed:
U trunk/dabo/db/dbMsSQL.py
U trunk/dabo/db/dbMySQL.py
Log:
Updated these backends to work with dicts rather than tuples.
Diff:
Modified: trunk/dabo/db/dbMsSQL.py
===================================================================
--- trunk/dabo/db/dbMsSQL.py 2007-08-24 00:48:03 UTC (rev 3330)
+++ trunk/dabo/db/dbMsSQL.py 2007-08-24 01:19:29 UTC (rev 3331)
@@ -76,14 +76,14 @@
" order by table_name",
{'db':dbName} )
rs = cursor.getDataSet()
- tables = [x[0] for x in rs]
+ tables = [x["table_name"] for x in rs]
tables = tuple(tables)
return tables
def getTableRecordCount(self, tableName, cursor):
cursor.execute("select count(*) as ncount from '%(tablename)'"
% tableName)
- return tempCursor.getDataSet()[0][0]
+ return cursor.getDataSet()[0]["ncount"]
def _fieldTypeNativeToDabo(self, nativeType):
@@ -179,9 +179,9 @@
fields = []
for r in fieldDefs:
- name = r[0]
- ft = self._fieldTypeNativeToDabo(r[1])
- pk = (name,) in pkFields
+ name = r["column_name"]
+ ft = self._fieldTypeNativeToDabo(r["data_type"])
+ pk = (name,) in [(p["column_name"], ) for p in pkFields]
fields.append((name, ft, pk))
return tuple(fields)
Modified: trunk/dabo/db/dbMySQL.py
===================================================================
--- trunk/dabo/db/dbMySQL.py 2007-08-24 00:48:03 UTC (rev 3330)
+++ trunk/dabo/db/dbMySQL.py 2007-08-24 01:19:29 UTC (rev 3331)
@@ -97,7 +97,7 @@
def _isExistingTable(self, tablename, cursor):
tbl = self.encloseNames(self.escQuote(tablename))
cursor.execute("SHOW TABLES LIKE %s" % tbl)
- rs = tempCursor.getDataSet()
+ rs = cursor.getDataSet()
return bool(rs)
@@ -105,37 +105,28 @@
# MySQL doesn't have system tables, in the traditional sense,
as
# they exist in the mysql database.
cursor.execute("show tables")
- rs = tempCursor.getDataSet()
+ # Non-select statements don't get read into the data set
+ rs = cursor.fetchall()
tables = []
for record in rs:
- tables.append(record[0])
+ tables.append(record.values()[0])
return tuple(tables)
def getTableRecordCount(self, tableName, cursor):
cursor.execute("select count(*) as ncount from %s" %
self.encloseNames(tableName))
- return tempCursor.getDataSet()[0][0]
+ return cursor.getDataSet()[0]["ncount"]
def getFields(self, tableName, cursor):
if not tableName:
return tuple()
cursor.execute("describe %s" % self.encloseNames(tableName))
- rs = cursor.getDataSet()
- fldDesc = cursor.description
- # The field name is the first element of the tuple. Find the
- # first entry with the field name 'Key'; that will be the
- # position for the PK flag
- pkPos = 0
- for i in range(len(fldDesc)):
- if fldDesc[i][0] == "Key":
- pkPos = i
- break
-
+ rs = cursor.fetchall()
fields = []
for r in rs:
- name = r[0]
- ft = r[1]
+ name = r["Field"]
+ ft = r["Type"]
if ft.split()[0] == "tinyint(1)" or "bit" in ft:
ft = "B"
elif "int" in ft:
@@ -167,8 +158,7 @@
ft = "C"
else:
ft = "?"
- pk = (r[pkPos] == "PRI")
-
+ pk = (r["Key"] == "PRI")
fields.append((name.strip(), ft, pk))
return tuple(fields)
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/dabo-dev/[EMAIL PROTECTED]