[PyKDE] Re: PyQt application freezing on long operations
hpj at urpla.net
Mon Jan 22 22:07:21 GMT 2007
Am Montag, 22. Januar 2007 22:25 schrieb Carlos Eduardo:
> Hans-Peter Jansen <hpj <at> urpla.net> writes:
> > You're way to sparse with description of your environment/approaches to
> > give you helpful answers.
> > One nice thing of Qt3 QDataTables is, you don't need to care about the
> > number of rows, at least as long as the database[server] is fast enough
> > to deliver the first bunch of records (500?). Qt manages the "fetch
> > when used" quite effective behind the scenes. I'm using it on tables
> > with 60000 records without noticable delays - as long as I don't try to
> > iterate through the result set myself.
> > KR,
> > Pete
> I´m using Python 2.5, Qt4.2.2 and latest PyQt snapshot... i made the
> application DB access using sqlite3 and cx_Oracle modules, for each of
> them I created a class that has the same functionaliti for all DB´s (get
> tables, make queries, get indexes...) .. like a wrapper for underlying
> I did exactly what you said... i´m iterating myself over the results, and
> inserting them on the table.
> Here a example on what i did:
> lines = query()
> for line in lines:
> def query():
> cursor.execute('select * from abc')
> return cursor.fetchall()
This approach is very painful (runtime and memory wise), as you experienced.
If I had written my apps in this style, some of them won't be up until after
lunch, if not prematurely slaughtered by the oom killer, when started early
in the morning (something I struggle with anyway ;-)..
I did something like this way back in Python-Tk times - watch your heap!
You will soon start playing LIMIT games or..
> I will look into QT classes for data handling tomorrow...
I haven't worked with PyQt4 yet, but I guess, this move will pay off soon.
You're welcome and remember, the PyQt wiki could very well take some
More information about the PyQt