fix database not global variable error - due to switch orm from skylark to peewee