Update db.py

fixed missing None-Check