fix a bug in database.py