diff --git a/libs/fingerprint.py b/libs/fingerprint.py index fc7385e..82dde61 100644 --- a/libs/fingerprint.py +++ b/libs/fingerprint.py @@ -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) diff --git a/main.py b/main.py index b5a5996..5240d2d 100644 --- a/main.py +++ b/main.py @@ -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)