FIN: database schema writing of tables info
This commit is contained in:
parent
0fd3ab06f9
commit
983995ef5b
|
@ -44,6 +44,10 @@ class DBSchema:
|
|||
return 1
|
||||
|
||||
|
||||
def importDBSchema(self, filein):
|
||||
return
|
||||
|
||||
|
||||
def __openDB(self, filein):
|
||||
conn = sqlite3.connect(filein)
|
||||
cur = conn.cursor()
|
||||
|
@ -69,12 +73,21 @@ class DBSchema:
|
|||
|
||||
|
||||
def writeFingerprint(self, filehandle):
|
||||
thash = {}
|
||||
keys = self.tables.keys()
|
||||
for key in keys:
|
||||
thash[key] = self.tables[key].fields
|
||||
json.dump(thash, filehandle, sort_keys=True, indent=4)
|
||||
|
||||
|
||||
def writeFingerprint2(self, filehandle):
|
||||
keys = self.tables.keys()
|
||||
for key in keys:
|
||||
tableDef = self.tables[key]
|
||||
tableDef.toFile(filehandle);
|
||||
|
||||
|
||||
|
||||
def getErrorString(self, errorCode):
|
||||
retval = "ERROR: unknown error code: " + str(errorCode)
|
||||
if (errorCode == -2):
|
||||
|
@ -170,7 +183,6 @@ class TableDefinition:
|
|||
newField['name'] = results.group(1)
|
||||
newField['datatype'] = results.group(2)
|
||||
newField['primarykey'] = True
|
||||
newField['autoincrement'] = True
|
||||
return newField
|
||||
# FileID INTEGER NOT NULL
|
||||
results = re.match(r'(?:[`|\"|\'])*(\w+)(?:[`|\"|\'])*\s+(\w+)\s+NOT NULL', sqltext)
|
||||
|
@ -211,6 +223,10 @@ class TableDefinition:
|
|||
return None
|
||||
|
||||
|
||||
def fields(self):
|
||||
return self.fields
|
||||
|
||||
|
||||
def toJSON(self):
|
||||
print json.dumps(self.fields)
|
||||
|
||||
|
|
Loading…
Reference in New Issue