Database: implemented lazy database connection