Connect to DB in queries