diff --git a/libs/fingerprint.py b/libs/fingerprint.py index b8dcbef..7835843 100644 --- a/libs/fingerprint.py +++ b/libs/fingerprint.py @@ -62,7 +62,10 @@ class DBSchema: def writeFingerprint(self): keys = self.tables.keys() for key in keys: + print "[[ TABLE: <" + key + "> ]]" tableDef = self.tables[key] + # hehehe = tableDef.SQLstr() + print str(tableDef.SQLstr()) tableDef.toJSON() return @@ -101,7 +104,7 @@ class TableDefinition: if results: colstr = results.group(1) print "[[ TABLE: <" + tableName + "> ]]" - print "FIELDS: " + colstr + # print "FIELDS: " + colstr columns = colstr.split(',') for col in columns: newField = self.__parseCreateStr(col.strip()) @@ -159,20 +162,20 @@ class TableDefinition: newField['datatype'] = results.group(2) newField['notnull'] = True return newField + # PRIMARY KEY (field_name, + results = re.match(r'PRIMARY KEY \((\w+)\,?', sqltext) + if results: + field = self.fields[results.group(1)] + field['primarykey'] = True + return False # custom_ringtone TEXT results = re.match(r'(\w+)\s+(\w+)', sqltext) if results: newField['name'] = results.group(1) newField['datatype'] = results.group(2) return newField - # PRIMARY KEY (field_name, - results = re.match(r'PRIMARY KEY \((\w+)\,', sqltext) - if results: - field = self.fields[results.group(1)] - field['primarykey'] = True - return False # field_name) - results = re.match(r'(\w+)\)', sqltext) + results = re.match(r'\,?(\w+)\)', sqltext) if results: field = self.fields[results.group(1)] field['primarykey'] = True @@ -207,10 +210,7 @@ class TableDefinition: return self.tableName - -class TableField: - - def __init__(self): - return + def SQLstr(self): + return self.sqlStr diff --git a/main.py b/main.py index e202cd7..f384c35 100644 --- a/main.py +++ b/main.py @@ -15,6 +15,7 @@ def main(): retVal = db.scanDBFile(filein) if (retVal > 0): + print "\n\n" db.writeFingerprint() else: print db.getErrorString(retVal) diff --git a/test-data/contacts2.db b/test-data/contacts2.db old mode 100644 new mode 100755 diff --git a/test-data/example.json b/test-data/example.json new file mode 100644 index 0000000..a838039 --- /dev/null +++ b/test-data/example.json @@ -0,0 +1,14 @@ + +{ + "tables": { + "table_def_1": { + + }, + "table_def_2": { + + }, + "table_def_3": { + + } + } +} \ No newline at end of file