[Lazarus] Multithreaded app with PostgreSQL connection
Ondrej Pokorny
lazarus at kluug.net
Mon Jun 20 18:08:24 CEST 2016
Hello!
I have a multithreaded application where every thread needs to connect
to the same PostgreSQL database. How to design the DB connectivity for a
multithreaded application correctly?
I see that TPQConnection has an FConnectionPool. So is it thread-safe?
Create a TPQConnection in the main thread; create
TSQLQuery+TSQLTransaction in a (different) thread and connect it to to
the TPQConnection from main thread via the Database property?
Or do I need a TPQConnection per thread?
I somehow failed to find any information about sqldb and multithreading:
http://www.freepascal.org/docs-html/fcl/sqldb/index.html
http://wiki.freepascal.org/SQLdb_Programming_Reference
Thanks :)
Ondrej
More information about the Lazarus
mailing list