Added some better handling of SQL connection errors, also now disconnects after query.
Added support for testing prefix changes.