On 12/6/06, Barry Warsaw <[EMAIL PROTECTED]> wrote:
> I'm still confused about the row keys though.  They aren't exactly
> the names of the columns in my table, they are prepended with the
> table name, lowercased.  E.g. my table is named Listdata and the
> columns are host_name and list_name but the keys are
> listdata_host_name and listdata_list_name.  Is this expected?  Why is
> it this way?

That one I think I can explain.

SQLAlchemy's RowProxy objects let you access their columns in all
sorts of ways: by numerical index like row[0], by dictionary lookup
like row['username'], or even by attribute access like row.password.
Now, what happens if you do:

SELECT users.name, maillist.name FROM users, maillist WHERE some_condition()

and you want to access the "users.name" attribute? That's why column
labels are used. See
http://www.sqlalchemy.org/docs/sqlconstruction.myt#sql_select_labels
for details; basically, it's easier to give the RowProxy object
attributes like row.users_name and row.maillist_name than to make
"row.users.name" and "row.maillist.name" work.

At least, that's my understanding of why this works the way it does.
If Michael Bayer says something different, listen to him, not me. :-)

-- 
Robin Munn
[EMAIL PROTECTED]
GPG key 0x4543D577

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to