Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm not a SO god, but I do have some input. My main experience with SQL in Python is with Django.</p> <p>The solution matters on what you're willing to commit to. If you want to stick with using the Qt libraries and just the PyQt libraries, then go with QtSql. If you want to just build your application quickly but pull in a few more dependencies, then I'd go with SQLAlchemy. You might run into some issues like the <a href="https://stackoverflow.com/questions/2397987/using-pyqt4-qtableview-with-sqlalchemy-using-qsqltablemodel-or-not">asker of this question</a>, and then you would need to pull in more libraries or pull out your hair.</p> <p>So, in a nice list style:</p> <h2>MySQLdb</h2> <ul> <li>pro: Pure SQL</li> <li>con: Ugly</li> <li>con: requies you to write SQL</li> <li>con: requires you to manage the cursor, doesn't do any caching, parameterization, etc...</li> <li>con: can't switch to a different database backend without rewriting all of your database code</li> </ul> <p><strong>VERDICT:</strong> don't use this for anything that you would put into production</p> <h2>QtSQL</h2> <ul> <li>pro: Only uses Qt libraries</li> <li>pro: will return Qt objects, so it will integrate with Qt's standard widgets</li> <li>pro: can use any database backend that Qt supports</li> <li>con: still requires you to write SQL</li> </ul> <p><strong>VERDICT:</strong> choose this if you want to write less UI code and more database code</p> <h2>SQLAlchemy</h2> <ul> <li>pro: all database logic can be written out in Python code (since it's an ORM)</li> <li>pro: supports many database backends</li> <li>con: might require some extra configuration to get things working nicely with Qt</li> </ul> <p><strong>VERDICT:</strong> choose this if you want to write less database code and would be fine with solving some API issues.</p> <hr> <p>Also, don't bother worrying about performance with any choice -- they should all be roughly equivalent, and the majority of the time will be spent on I/O.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload