Completed crude MySQL implementation