"Che M" <[EMAIL PROTECTED]> wrote

The reason is merely lack of experience and because of how I was
using the fetchall() in one list comprehension to build each list...

> (heck, you could select code, start, style form codes -- pull all > the
> information you need in a single query, and skip the loop

I think I need the loop because the style will be multiple styles and
I need to take the codes that go with each style, so I am querying
style by style, so to speak.

Check out the GROUP BY and ORDER BY clauses of a SELECT
statement. I'm pretty sure you could select all the stuff you want
using a combination of those two clauses. It should be much faster
and lead to more maintainable code too. Something like:

select code from codes where code != '' and style = ? and
start >= ? and start < ?

SELECT code, start
FROM codes
WHERE code != "" AND start >= begin AND start < end
GROUP BY style
ORDER BY style

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to