Fix PY3 hasattr connecting to the db at define time