'''
tableName:
a b
--------------
as uu
'''
conn = MySQLdb.connect (host = "localhost",
user = "root",
passwd = "",
db = "dbName",
cursorclass=MySQLdb.cursors.DictCursor
)
cursorDict = conn.cursor()
cursorDict.execute("SELECT * FROM tableName")
rowDict = cursorDict.fetchone()
print rowDict
# this will print {"a":"as", "b":"uu"}
Friday, November 19, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment