[newbie] Right way to access item in array?
Diez B. Roggisch
deets at nospam.web.de
Tue Oct 28 11:33:11 CET 2008
Gilles Ganault wrote:
> I'd like to know what the right way is to access an item in a row as
> returned by a database:
> import apsw
> rows=cursor.execute("SELECT isbn,price FROM books WHERE price IS
> for row in rows:
> #Is this right?
> for isbn in row:
No. This will iterate though all columns, not just the isbn.
You can use tuple-unpacking in such cases:
for row in rows:
isbn, price = row
More information about the Python-list