Home > Articles > Open Source > Python

  • Print
  • + Share This
Like this article? We recommend

Like this article? We recommend

Qt SQL and Data-Aware Widgets

If you want to trade the flexibility DB-API II offers for ease of prototyping, you can use PyQt, which wraps Qt's data-aware controls. Qt, a cross-platform GUI library (Windows, UNIX/X11, OS X), comes with a complete set of classes to access databases. Currently supported are MySQL, Oracle (via the OCI interface, which is really fast), ODBC, PostgreSQL, and Sybase/Microsoft SQL Server.

Some experimental evidence suggests that it can be quite hard to compile database drivers for Qt—but it can be equally hard for DB-API II.

From a developer's point of view, there are basically two approaches to a standalone GUI database application: using data-aware controls or widgets and letting the library do the heavy lifting of records and fields from the database, or using vanilla controls or widgets and doing the retrieving, inserting, deleting, and updating of records yourself.

You might assume that the first option would be the most popular because it evidently takes least time to develop. Unfortunately, that is seldom true. The problem with most data-aware GUI controls or widgets is that the database connection code behind that GUI control is simple—often even simple-minded. Perhaps it's suitable for small one-off applications, but not for real-world projects. Another point against using data-aware controls is that they lead to a simple, two-tiered architecture in which it might be difficult to change databases.

I have about a decade of experience with building database applications with Oracle, Visual Basic, and Java. Only Oracle Forms have stood up to the challenge, mainly because once you decide to use Oracle Forms, you've also decided to use an Oracle database. Visual Basic and Java both forced our development team to separate the GUI application from the data-handling code—which might be a very good thing, too.

With the advent of Web applications based on databases, the wisdom of tying up the database access code into the GUI client is even more questionable. However, to provide a full palette of choices, Python should offer data-aware controls, too.

  • + Share This
  • 🔖 Save To Your Account