Connecting to database and getting data