Databases: Getting values by column name
Skip Montanaro
skip at pobox.com
Tue Aug 17 22:32:18 EDT 2004
>> conn = MySQLdb.Connection(host=...,
Robert> You mean MySQLdb.connect()?
MySQLdb has Connect, connect and Connection, all the same function.
>>> MySQLdb.Connection
<function Connect at 0xdc2930>
>>> MySQLdb.Connect
<function Connect at 0xdc2930>
>>> MySQLdb.connect
<function Connect at 0xdc2930>
>> I think the reason this sort of behavior isn't spelled out in PEP 249
>> is because it varies too much from one database to another. Psycopg
>> (a PostgreSQL adaptor) does it differently. Instead of specifying
>> the cursor type when the connection is created, you instantiate a
>> different cursor class:
>>
>> conn = psycopg.connect("...")
Robert> NameError: name 'psycopg' is not defined
Yes, you'd have to import it.
Robert> Also wouldn't that overwrite the above conn variable?
>> ...
>> cursor = conn.dictcursor()
Robert> AttributeError: Connection instance has no attribute 'dictcursor'
Like I said, psycopg is an adapter for the PostgreSQL database. MySQLdb is
an adapter for the MySQL database. There are others as well. I thought
showing how the two I'm most familiar with in this arena differ would be
sufficient.
Robert> I already know the stuff on that page, it's really slowing you
Robert> down :-(
I don't understand what you're referring to here. What do you mean by
"slowing you down"?
Skip
More information about the Python-list
mailing list