Re: [Tutor] problem with building dict w/ SQlite SELECTS in loop

2008-09-16 Thread Alan Gauld
"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

Re: [Tutor] problem with building dict w/ SQlite SELECTS in loop

2008-09-16 Thread John Fouhy
2008/9/17 Che M <[EMAIL PROTECTED]>: >> (heck, you could select code, start, style form codes -- pull all the >> information you need in a single query, and skip the loop >> altogether..) > I think I need the loop because the style will be multiple styles and > I need to take the codes that go with

Re: [Tutor] problem with building dict w/ SQlite SELECTS in loop

2008-09-16 Thread Che M
> I can't see any obvious reasons for your problems, I'm afraid, but I > do have a comment on your SQL: the sqlite module supports using ? to > indicate parameters. So you could rewrite your select statements as: > > cur.execute("select code from codes where code != '' and style = ? and > start

Re: [Tutor] problem with building dict w/ SQlite SELECTS in loop

2008-09-16 Thread Tim Golden
Che M wrote: [... snip solution around mis-handling a string split ...] Glad you solved it. Thanks for coming back with an update. Depending on your circs, you might want to try a more general solution to that problem, like: s = "This, is,a, string, with, varying, amounts, of,space" print

Re: [Tutor] problem with building dict w/ SQlite SELECTS in loop

2008-09-16 Thread Tim Golden
Che M wrote: [... snip solution around mis-handling a string split ...] Glad you solved it. Thanks for coming back with an update. Depending on your circs, you might want to try a more general solution to that problem, like: s = "This, is,a, string, with, varying, amounts, of,space" print

Re: [Tutor] problem with building dict w/ SQlite SELECTS in loop

2008-09-16 Thread Che M
> I'm quite willing to help on this, but it's just not quite > clear enough what's happening. Can I suggest that you > post a *really small, self-contained* example which demonstrates > the problem you're having. You might actually realise what's > wrong as you do that, or if not someone like me

Re: [Tutor] problem with building dict w/ SQlite SELECTS in loop

2008-09-16 Thread Tim Golden
Che M wrote: (struggling to make an informative subject line) [ struggling to understand exactly what the problem is... :) ] I'm quite willing to help on this, but it's just not quite clear enough what's happening. Can I suggest that you post a *really small, self-contained* example which demo

Re: [Tutor] problem with building dict w/ SQlite SELECTS in loop

2008-09-15 Thread John Fouhy
2008/9/16 Che M <[EMAIL PROTECTED]>: > for style in self.style_list: > > #Get the codes... > cur.execute('SELECT code FROM Codes WHERE code != "" AND Style= "' + > style + '" > AND start >=' + '"' + self.start_datestring + '"' + 'AND start < "' > + self.end_datestring + '"') > m

[Tutor] problem with building dict w/ SQlite SELECTS in loop

2008-09-15 Thread Che M
(struggling to make an informative subject line) Hi, I have what is no-doubt a dumb problem, but I can't get past it... Given a list of items, I want to loop through the list, use the item in a SELECT statement to query an SQLite database, and use the returned data from a .fetchall() to add