Re: [Newbie] Strange output from list

2008-11-11 Thread Steve Holden
Chris Rebert wrote: > On Tue, Nov 11, 2008 at 12:56 AM, Gilles Ganault <[EMAIL PROTECTED]> wrote: >> On Mon, 10 Nov 2008 20:02:39 -0600, Andrew <[EMAIL PROTECTED]> wrote: >>> sql = 'SELECT id FROM master' >>> rows=list(cursor.execute(sql)) >>> for id in rows: >>> sql = 'SELECT COUNT(code) FRO

Re: [Newbie] Strange output from list

2008-11-11 Thread Chris Rebert
On Tue, Nov 11, 2008 at 12:56 AM, Gilles Ganault <[EMAIL PROTECTED]> wrote: > On Mon, 10 Nov 2008 20:02:39 -0600, Andrew <[EMAIL PROTECTED]> wrote: >>sql = 'SELECT id FROM master' >>rows=list(cursor.execute(sql)) >>for id in rows: >> sql = 'SELECT COUNT(code) FROM companies WHERE code="%s"' %

Re: [Newbie] Strange output from list

2008-11-11 Thread Gilles Ganault
On Mon, 10 Nov 2008 20:02:39 -0600, Andrew <[EMAIL PROTECTED]> wrote: >sql = 'SELECT id FROM master' >rows=list(cursor.execute(sql)) >for id in rows: > sql = 'SELECT COUNT(code) FROM companies WHERE code="%s"' % id[0] > result = list(cursor.execute(sql)) > print "Code=%s, number=%

Re: [Newbie] Strange output from list

2008-11-10 Thread Ben Finney
Andrew <[EMAIL PROTECTED]> writes: > (47,) is the python representation of a one item tuple It's also the representation of a one-column result row, which is more pertinent here. Just because ‘str(foo) == str(bar)’, does *not* necessarily mean ‘type(foo) == type(bar)’, nor even ‘isinstance(foo,

Re: [Newbie] Strange output from list

2008-11-10 Thread Andrew
Ben Finney wrote: > Gilles Ganault <[EMAIL PROTECTED]> writes: > > >> Hello >> >> I'm getting some unwanted result when SELECTing data from an SQLite >> database: >> >> == >> sql = 'SELECT id FROM master' >> rows=list(cursor.execute(sql)) >> for id in rows: >> sql = 'SELECT COUNT(code)

Re: [Newbie] Strange output from list

2008-11-10 Thread Ben Finney
My apologies, my response was rather confused. Ben Finney <[EMAIL PROTECTED]> writes: > The result of an SQL SELECT is a sequence of tuples, where each item > in the tuple is a value for a column as specified in the SELECT > clause. This remains true. No matter how many columns you specify in th

Re: [Newbie] Strange output from list

2008-11-10 Thread Ben Finney
Gilles Ganault <[EMAIL PROTECTED]> writes: > Hello > > I'm getting some unwanted result when SELECTing data from an SQLite > database: > > == > sql = 'SELECT id FROM master' > rows=list(cursor.execute(sql)) > for id in rows: > sql = 'SELECT COUNT(code) FROM companies WHERE code="%s"' %

[Newbie] Strange output from list

2008-11-10 Thread Gilles Ganault
Hello I'm getting some unwanted result when SELECTing data from an SQLite database: == sql = 'SELECT id FROM master' rows=list(cursor.execute(sql)) for id in rows: sql = 'SELECT COUNT(code) FROM companies WHERE code="%s"' % id[0] result = list(cursor.execute(sql)) prin