FIN: database schema writing of tables info

This commit is contained in:
JohnE 2015-06-12 00:53:29 -07:00
parent 0fd3ab06f9
commit 983995ef5b
2 changed files with 18 additions and 2 deletions

View File

@ -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)

View File

@ -33,7 +33,7 @@ def parseArgs():
args = parser.parse_args()
if (args.verbose):
verbose = args.verbose
fileout = args.file + "_" + timestr
fileout = args.file + "_" + timestr + '.json'
return (args.file, fileout, verbose)