Question abbout threaded HandleURLs

I am using the App.HandleURL event to update a Postgres database on a cloud server. If I have multiple connections at the same time, am I going to have trouble with the single connection? I found that if I begin a transaction and write data to multiple tables, I get an error about the transaction needing to be closed first as soon as I wrote to the second table. This did not happen with similar code using SQLite and MySQL databases. I am concerned that data will be lost if multiple HandleURL threads are trying to write at the same time. Would opening a separate database connection with each thread be a good idea?

Since this is a meter reading application, I expect many devices to all be sending data at the same time, every 15 minutes on the quarter hour.

You really should be using a separate database connection in HandleURL regardless of the back end you are using.

Xojo will make a new thread for each request and run the processing on the thread.
So you may have multiple request running in parallel.
Sind ExecuteSQL and similar functions may yield to other threads while waiting for an answer from database server, So you muss use different connections to database for each. Either with pooling and reusing or just by opening a new one each time.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.