[PyQt] PyQt and DB API.

Hans-Peter Jansen hpj at urpla.net
Sat May 17 23:52:59 BST 2008

Am Samstag, 17. Mai 2008 schrieb objectref:
> Hi,
> I am reading Mark Summerfield's book ("Rapid GUI programming with Python
> and Qt"). So, in chapter 15 (Databases), he states that "Python also has
> its own completely different database API, called DB-API but it isn't
> needed with PyQt."
> I think I need a direction on this:
> I always thought that I should be doing stuff by using functionality that
> the language (or its library) provides and if this is not possible, then
> (and only then) I would look for the solution in another library, module,
> toolkit etc.
> So, here the standard is DB API but PyQt uses something different. I plan
> to access Sql Server databases (mostly) but it would be nice to have my
> code such that it can easily be ported to some other DB in the future (I
> know that I can code it such way in PyQt.)
> As I have the opinion that "standard" is a good thing, do you think that
> I better use some other module that is DB-API compliant or PyQt is best
> to be used in this case?

Apart from what Andreas' already said, PyQt does some nice things behind 
your back, e.g. allows you to display huge tables without big fuzz (by 
delaying access to not yet displayed records).

What I don't like about PyQt's database API is the sometimes arkward 
fiddling (from a python perspective) with QVariants, given that some 
automatic Qt (C++) coercions are not available within PyQt. 


More information about the PyQt mailing list