correct sql for databases, add environment flag to run script