<div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif">​</div><div class="gmail_extra"><br></div><div class="gmail_quote">On 31 March 2018 at 14:02, Ricardo Araoz <span dir="ltr"><<a href="mailto:ricaraoz@gmail.com" target="_blank">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">
  
    
  
  <div bgcolor="#FFFFFF"><span>
    On 31/03/18 12:37, J Barchan wrote:<br>
    </span><blockquote type="cite">
      <div dir="ltr">
        <div style="font-family:tahoma,sans-serif">​</div>
        <div class="gmail_extra"><span><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">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>
          </span><span><div style="font-family:tahoma,sans-serif">​Hi Ricardo,</div>
          <div style="font-family:tahoma,sans-serif"><br>
          </div>
          <div style="font-family:tahoma,sans-serif">I am not a PyQt expert
            person --- just someone using it.</div>
          <div style="font-family:tahoma,sans-serif"><br>
          </div>
          <div style="font-family:tahoma,sans-serif">I would say basically
            "no".  ​<div class="gmail_default" style="font-family:tahoma,sans-serif;display:inline">​​</div><font face="monospace,monospace">QSqlRelationalTableModel
            </font><span class="gmail-m_-6466530370896208889gmail-J-J5-Ji" id="gmail-m_-6466530370896208889gmail-: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 style="font-family:tahoma,sans-serif"><br>
          </div>
          <div 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-m_-6466530370896208889gmail-J-J5-Ji" id="gmail-m_-6466530370896208889gmail-: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 style="font-family:tahoma,sans-serif"><span class="gmail-m_-6466530370896208889gmail-J-J5-Ji"><br>
            </span></div>
          <div style="font-family:tahoma,sans-serif"><span class="gmail-m_-6466530370896208889gmail-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/" target="_blank">https://forum.qt.io/</a> and come
              pose your question there.</span></div>
          <div style="font-family:tahoma,sans-serif"><span class="gmail-m_-6466530370896208889gmail-J-J5-Ji"><br>
              -- <br>
            </span></div>
          <div class="gmail-m_-6466530370896208889gmail_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>
        </span></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<span class="gmail-HOEnZb"><font color="#888888"><br>
    Ricardo<br>
    <br>
  </font></span></div>

</blockquote></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><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"><div class="gmail_default" style="font-family:tahoma,sans-serif;display:inline">​<font face="Arial">But I'd be missing the automatic behaviour implemented by the    model/view/delegate schema</font></div></blockquote><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">​</div><div class="gmail_default" style="font-family:tahoma,sans-serif">​Why would you be missing any of this?​</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><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">I'm now thinking about subclassing the    model and implementing something in the submit and submitAll    methods</blockquote><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Yes, in case I wasn't clear, of course you should not throw away anything like the ​<font face="monospace,monospace">QSqlRelationalTableModel</font> level.  You would use that and write your own sub-classes/super-classes/wrappers to add the functionality you want on top of what is already there, not replacing it.  The approaches I was suggesting would be in that vein.  But my point is you do need to write the new stuff yourself, unless you can find anything which does this for you, which I am not aware of.</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">I have been thinking for a while ​I'd quite like to add ​something of a "<font face="monospace,monospace">QSqlDataSet</font>" class/level to Qt to encapsulate the relationships between multiple <font face="monospace,monospace">QSqlRelationalTableModel</font>s, and so much more.  Do you think that would be a good idea?<br clear="all"><br>-- <br></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 class="gmail_extra">
</div></div>