Changeset 3331

Show
Ignore:
Timestamp:
08/23/07 18:19:29 (1 year ago)
Author:
ed
Message:

Updated these backends to work with dicts rather than tuples.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/db/dbMsSQL.py

    r3323 r3331  
    7777             {'db':dbName} ) 
    7878        rs = cursor.getDataSet() 
    79         tables = [x[0] for x in rs] 
     79        tables = [x["table_name"] for x in rs] 
    8080        tables = tuple(tables) 
    8181        return tables 
     
    8484    def getTableRecordCount(self, tableName, cursor): 
    8585        cursor.execute("select count(*) as ncount from '%(tablename)'" % tableName) 
    86         return tempCursor.getDataSet()[0][0
     86        return cursor.getDataSet()[0]["ncount"
    8787         
    8888 
     
    180180        fields = [] 
    181181        for r in fieldDefs: 
    182             name = r[0
    183             ft = self._fieldTypeNativeToDabo(r[1]) 
    184             pk = (name,) in pkFields 
     182            name = r["column_name"
     183            ft = self._fieldTypeNativeToDabo(r["data_type"]) 
     184            pk = (name,) in [(p["column_name"], ) for p in pkFields] 
    185185            fields.append((name, ft, pk)) 
    186186        return tuple(fields) 
  • trunk/dabo/db/dbMySQL.py

    r3323 r3331  
    9898        tbl = self.encloseNames(self.escQuote(tablename)) 
    9999        cursor.execute("SHOW TABLES LIKE %s" % tbl) 
    100         rs = tempCursor.getDataSet() 
     100        rs = cursor.getDataSet() 
    101101        return bool(rs) 
    102102             
     
    106106        # they exist in the mysql database. 
    107107        cursor.execute("show tables") 
    108         rs = tempCursor.getDataSet() 
     108        # Non-select statements don't get read into the data set 
     109        rs = cursor.fetchall() 
    109110        tables = [] 
    110111        for record in rs: 
    111             tables.append(record[0]) 
     112            tables.append(record.values()[0]) 
    112113        return tuple(tables) 
    113114         
     
    115116    def getTableRecordCount(self, tableName, cursor): 
    116117        cursor.execute("select count(*) as ncount from %s" % self.encloseNames(tableName)) 
    117         return tempCursor.getDataSet()[0][0
     118        return cursor.getDataSet()[0]["ncount"
    118119 
    119120 
     
    122123            return tuple() 
    123124        cursor.execute("describe %s" % self.encloseNames(tableName)) 
    124         rs = cursor.getDataSet() 
    125         fldDesc = cursor.description 
    126         # The field name is the first element of the tuple. Find the 
    127         # first entry with the field name 'Key'; that will be the  
    128         # position for the PK flag 
    129         pkPos = 0 
    130         for i in range(len(fldDesc)): 
    131             if fldDesc[i][0] == "Key": 
    132                 pkPos = i 
    133                 break 
    134          
     125        rs = cursor.fetchall() 
    135126        fields = [] 
    136127        for r in rs: 
    137             name = r[0
    138             ft = r[1
     128            name = r["Field"
     129            ft = r["Type"
    139130            if ft.split()[0] == "tinyint(1)" or "bit" in ft: 
    140131                ft = "B" 
     
    168159            else: 
    169160                ft = "?" 
    170             pk = (r[pkPos] == "PRI") 
    171              
     161            pk = (r["Key"] == "PRI") 
    172162            fields.append((name.strip(), ft, pk)) 
    173163        return tuple(fields)