<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
On 31/03/18 12:37, J Barchan wrote:<br>
<blockquote type="cite"
cite="mid:CABz3M_-WDzPZMvoywoKjru24Oub7a_bH4BsxA+cb+x9V66+dgQ@mail.gmail.com">
<div dir="ltr">
<div class="gmail_default" style="font-family:tahoma,sans-serif"></div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 30 March 2018 at 16:48, Ricardo
Araoz <span dir="ltr"><<a
href="mailto:ricaraoz@gmail.com" target="_blank"
moz-do-not-send="true">ricaraoz@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">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.<br>
<br>
TIA<br>
</blockquote>
</div>
<br>
<div class="gmail_default"
style="font-family:tahoma,sans-serif">Hi Ricardo,</div>
<div class="gmail_default"
style="font-family:tahoma,sans-serif"><br>
</div>
<div class="gmail_default"
style="font-family:tahoma,sans-serif">I am not a PyQt expert
person --- just someone using it.</div>
<div class="gmail_default"
style="font-family:tahoma,sans-serif"><br>
</div>
<div class="gmail_default"
style="font-family:tahoma,sans-serif">I would say basically
"no". <font face="monospace,monospace">QSqlRelationalTableModel
</font><span class="gmail-J-J5-Ji" id="gmail-:a9"></span>is
just a thin layer over <font face="monospace,monospace">QSqlTableModel</font>,
and that's just <font face="monospace,monospace">QSqlTableQuery</font>/<font
face="monospace,monospace">QSqlQuery </font>with some
support for putting it in a table and allowing you to
specify <font face="monospace,monospace">INSERT</font>/<font
face="monospace,monospace">DELETE</font>/<font
face="monospace,monospace">UPDATE </font>commands. Other
than that you're really on your own to add your own stuff.</div>
<div class="gmail_default"
style="font-family:tahoma,sans-serif"><br>
</div>
<div class="gmail_default"
style="font-family:tahoma,sans-serif">The usual way to
handle "multiuser" is to make your <font face="Courier New">DELETE</font>/<font
face="monospace,monospace">UPDATE </font><span
class="gmail-J-J5-Ji" id="gmail-:a9">statements do <em>optimistic
</em>updates, i.e. you add a <font
face="monospace,monospace">WHERE</font> 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 <em>pessimistic</em>
locking, where you lock the row when you read it, which
doesn't scale. You could implement these yourself.</span></div>
<div class="gmail_default"
style="font-family:tahoma,sans-serif"><span
class="gmail-J-J5-Ji"><br>
</span></div>
<div class="gmail_default"
style="font-family:tahoma,sans-serif"><span
class="gmail-J-J5-Ji">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 <a href="https://forum.qt.io/"
moz-do-not-send="true">https://forum.qt.io/</a> and come
pose your question there.</span></div>
<div class="gmail_default"
style="font-family:tahoma,sans-serif"><span
class="gmail-J-J5-Ji"><br>
-- <br>
</span></div>
<div class="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div><span style="font-family:tahoma,sans-serif">Kindest,</span></div>
<div><span style="font-family:tahoma,sans-serif">Jonathan</span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<br>
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.<br>
Cheers<br>
Ricardo<br>
<br>
</body>
</html>