Added database connection and data insertion. Needs refactoring.