|
4
|
Accessing database results by field name rather than field number is easy. I prefer standard, stable library like MySQLdb rather than private solutions. Look at the following code.
Other values for cursorclass are: Cursor This is the standard Cursor class that returns rows as tuples and stores the result set in the client. Warnings are raised as necessary. SSCursor This is a Cursor class that returns rows as tuples and stores the result set in the server. Warnings are raised as necessary. etc. Look at cursors.py source file of MySQLdb
Tags: database
|
1 comment
Add a comment
Sign in to comment
Download
Copy to clipboard

Hmmmm... I shy away from this one for big sets because each row is going to take up space with the dict keys. I do however combine this with Marteli's Struct class for struct like access ... cursorclass=StructCursor) ...
c.execute(sql) s = c.fetchone() s.col1 + s.col2