Changeset 3331
- Timestamp:
- 08/23/07 18:19:29 (1 year ago)
- Files:
-
- trunk/dabo/db/dbMsSQL.py (modified) (3 diffs)
- trunk/dabo/db/dbMySQL.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/dabo/db/dbMsSQL.py
r3323 r3331 77 77 {'db':dbName} ) 78 78 rs = cursor.getDataSet() 79 tables = [x[ 0] for x in rs]79 tables = [x["table_name"] for x in rs] 80 80 tables = tuple(tables) 81 81 return tables … … 84 84 def getTableRecordCount(self, tableName, cursor): 85 85 cursor.execute("select count(*) as ncount from '%(tablename)'" % tableName) 86 return tempCursor.getDataSet()[0][0]86 return cursor.getDataSet()[0]["ncount"] 87 87 88 88 … … 180 180 fields = [] 181 181 for r in fieldDefs: 182 name = r[ 0]183 ft = self._fieldTypeNativeToDabo(r[ 1])184 pk = (name,) in pkFields182 name = r["column_name"] 183 ft = self._fieldTypeNativeToDabo(r["data_type"]) 184 pk = (name,) in [(p["column_name"], ) for p in pkFields] 185 185 fields.append((name, ft, pk)) 186 186 return tuple(fields) trunk/dabo/db/dbMySQL.py
r3323 r3331 98 98 tbl = self.encloseNames(self.escQuote(tablename)) 99 99 cursor.execute("SHOW TABLES LIKE %s" % tbl) 100 rs = tempCursor.getDataSet()100 rs = cursor.getDataSet() 101 101 return bool(rs) 102 102 … … 106 106 # they exist in the mysql database. 107 107 cursor.execute("show tables") 108 rs = tempCursor.getDataSet() 108 # Non-select statements don't get read into the data set 109 rs = cursor.fetchall() 109 110 tables = [] 110 111 for record in rs: 111 tables.append(record [0])112 tables.append(record.values()[0]) 112 113 return tuple(tables) 113 114 … … 115 116 def getTableRecordCount(self, tableName, cursor): 116 117 cursor.execute("select count(*) as ncount from %s" % self.encloseNames(tableName)) 117 return tempCursor.getDataSet()[0][0]118 return cursor.getDataSet()[0]["ncount"] 118 119 119 120 … … 122 123 return tuple() 123 124 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() 135 126 fields = [] 136 127 for r in rs: 137 name = r[ 0]138 ft = r[ 1]128 name = r["Field"] 129 ft = r["Type"] 139 130 if ft.split()[0] == "tinyint(1)" or "bit" in ft: 140 131 ft = "B" … … 168 159 else: 169 160 ft = "?" 170 pk = (r[pkPos] == "PRI") 171 161 pk = (r["Key"] == "PRI") 172 162 fields.append((name.strip(), ft, pk)) 173 163 return tuple(fields)
