Database fixes for SCO/RCO in PostgreSQ and SQLite

Patches for issues #7 and #8 fixing server crashes when using SCO/RCO to access the database. Effects only the PostgreSQL and SQLite database connectors.