[PyQt] Going multiuser with QSqlRelationalTableModel
Ricardo Araoz
ricaraoz at gmail.com
Sat Mar 31 19:02:38 BST 2018
On 31/03/18 12:37, J Barchan wrote:
>
>
> On 30 March 2018 at 16:48, Ricardo Araoz <ricaraoz at gmail.com
> <mailto: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
>
>
> 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
Hi Jonathan, thanks for your answer. I know I could do it by myself, But
I'd be missing the automatic behaviour implemented by the
model/view/delegate schema. I'm now thinking about subclassing the model
and implementing something in the submit and submitAll methods.
Cheers
Ricardo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20180331/ea0a24ea/attachment.html>
More information about the PyQt
mailing list