Making database connection deferred