      ==================
        DB Fingerprint
      ==================


-------------
  INTRO
-------------
dbfp is a tool that will scan a sqlite database and generate a fingerprint.
The fingerprint is basically the database schema with some metadata (md5 sums, scan information)
The fingerprint is stored to disk in JSON format.


-------------
  BUILD
-------------
This project is completely python. No building required.
There are no dependencies.
It has been tested on Python 2.7.10


-------------
  LIBRARY
-------------
The following is documentation regarding the usage of the various libraries included 
with this tool.


[[ Fingerprint Library ]]
from libs.fingerprint import FingerprintDB
from libs.fingerprint_index import FingerprintIndex


[ Compare Fingerprint ]
db = FingerprintDB()
db.scanDBFile(file_in)
percent = db.compareDB(file_json)
print "Percent match: {}".format(str(percent))


[ Compare Fingerprint Index ]
db = FingerprintDB()
db.scanDBFile(file_in)

fp = FingerprintIndex()
fp.openIndex(fp_dir)
md5_db = db.getMD5DB()
md5_tables = db.getMD5Tables()
fp_list = fp.findFP(md5_db, md5_tables)
results = []
for fp in fp_list:
    fq_fp = fp_dir + os.path.sep + fp
    print "[ OPEN fingerprint ] [ {} ]".format(fq_fp)
    percent = db.compareDB(fq_fp)
    print "Percent: {}".format(str(percent))


[ Fingerprint Index Library ]
# create a fingerprint object
fp = FingerprintIndex()

# open the fingerprint index, this will create an index if not found
# parm1: path to the fingerprint index directory
fp.openIndex(fp_dir)

# parm1: database schema md5
# parm2: list of table schema md5
# return: list of fingerprints to open and compare
fp_list = fp.findFP(md5_db, md5_tables)

