Converted from sqlite to mysql