[PyQt] Extracting QSqlQuery results in PyQt4

Aaron Digulla digulla at hepe.com
Fri Oct 10 13:26:56 BST 2008


mir amicitas schrieb:

> With sqlite3 or apsw things are much more tolerable, though if any one has
> ideas on how to make the extraction even faster I would love to here them.
> What I am doing for now is to use:
> 
>  results = [row for row in self.cursor]

Try:

	results = list(self.cursor)

That might give another few ticks. And have a look at my code in UPCScan
0.6. There, I've moved the DB code into a background thread. This means
the UI can already be used while the DB code is still fetching data.

The next step would be to load the big table in chunks of, say, 25 rows
at a time by creating a select that returns only 25 rows, add them to
the table and start the fetch of the next 25 rows.

Or you can try to fetch as little data as possible. So the first query
would be to fetch only the number of rows in the table and return that
in your model without actually loading anything. Put N proxy objects
into the model (which should only take a few seconds).

When a proxy object is requested, load it (and maybe some more nearby
proxy objects). This way, you'll only load the data the user actually
wants to see.

Regards,

-- 
Aaron "Optimizer" Digulla a.k.a. Philmann Dark
"It's not the universe that's limited, it's our imagination.
Follow me and I'll show you something beyond the limits."
http://darkviews.blogspot.com/          http://www.pdark.de/


More information about the PyQt mailing list