convert db to sql