Fixing SQL arguments

SQL arguments were broken for systems using postgres databases. This
should now work for both postgres and sqlite arguments.

Also made some of the database constructors a bit simpler.