sqlalchemy: postgresql types support
legacy: support for postresql engine in dbquery

* Adds dynamic loading of legacy SQL functions for different database
  engines.  (addresses #2020)