[PyQt] Going multiuser with QSqlRelationalTableModel
J Barchan
jnbarchan at gmail.com
Sat Mar 31 16:37:37 BST 2018
On 30 March 2018 at 16:48, Ricardo Araoz <ricaraoz at gmail.com> wrote:
> Are there any methods for multiuser database programming while working
> with models and mappers? I mean, something to lock/unlock records and/or
> tables (not talking about transactions) and something that will tell me
> when saving if the database records to be updated have been changed since
> the model read them.
>
> TIA
>
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Hi Ricardo,
I am not a PyQt expert person --- just someone using it.
I would say basically "no". QSqlRelationalTableModel is just a thin layer
over QSqlTableModel, and that's just QSqlTableQuery/QSqlQuery with some
support for putting it in a table and allowing you to specify
INSERT/DELETE/UPDATE
commands. Other than that you're really on your own to add your own stuff.
The usual way to handle "multiuser" is to make your DELETE/UPDATE statements
do *optimistic *updates, i.e. you add a WHERE clause to verify all the
values in the database are the same as when you read the row in, else
someone else has changed it and then you error. That's instead of
*pessimistic* locking, where you lock the row when you read it, which
doesn't scale. You could implement these yourself.
Otherwise, this isn't a PyQt/Python question, so if you want to discuss in
detail or see if Qt experts have more to offer than I have you might like
to join up to https://forum.qt.io/ and come pose your question there.
--
Kindest,
Jonathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20180331/e67afe27/attachment.html>
More information about the PyQt
mailing list