moved the SQL connection code

lower overhead