Add some private functions to database.py