Connect to DB... build query from dictionary