Move db in __init__ a lambda to avoid None type errors during cleanup (python -v)