Improved SQL connections, connection is not closed after transaction

If this is still not fast enough, a connection pool can be easily
implemented for MySQL. For SQlite this is probably as fast as we can
get. Implementing internal queues could also be an option, but would
require one queue for each operation.