[Newbie] Strange output from list
Ben Finney
bignose+hates-spam at benfinney.id.au
Mon Nov 10 20:52:20 EST 2008
My apologies, my response was rather confused.
Ben Finney <bignose+hates-spam at benfinney.id.au> 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 the
SELECT clause, each result row is a tuple.
> SQLAlchemy represents this with a sequence of ResultProxy objects.
I mistakenly assumed you are using SQLAlchemy, which on re-reading
your post doesn't seem likely.
Instead, by the standard library ‘sqlite3’ module, you will receive
each result row as an ‘sqlite3.Row’ object:
A Row instance serves as a highly optimized row_factory for
Connection objects. It tries to mimic a tuple in most of its
features.
It supports mapping access by column name and index, iteration,
representation, equality testing and len().
<URL:http://docs.python.org/library/sqlite3.html#row-objects>
Since you only asked for the row to be printed, you therefore got a
string representation of the entire row (which mimics a Python tuple,
but is actually a different class with more functionality).
--
\ “Geeks like to think that they can ignore politics. You can |
`\ leave politics alone, but politics won't leave you alone.” |
_o__) —Richard Stallman, 2002-07-26 |
Ben Finney
More information about the Python-list
mailing list