added the database.py file

this should be equivalent to the c++ code.  only took about an hour to
do.