标签:style http io color ar os 使用 sp for
connection=MySQLdb.connect(
host="thehost",user="theuser",
passwd="thepassword",db="thedb")
cursor=connection.cursor()
cursor.execute(query)
for row in cursor.fetchall():
print(row)
import MySQLdb.cursors
connection=MySQLdb.connect(
host="thehost",user="theuser",
passwd="thepassword",db="thedb",
cursorclass = MySQLdb.cursors.SSCursor)
cursor=connection.cursor()
cursor.execute(query)
for row in cursor:
print(row)
CursorDictRowsMixIn
Causes the cursor to return rows as a dictionary, where the keys are column names and the values are column values. Note that if the column names are not unique, i.e., you are selecting from two tables that share column names, some of them will be rewritten as table.column. This can be avoided by using the SQL ASkeyword. (This is yet-another reason not to use * in SQL queries, particularly where JOIN is involved.)
标签:style http io color ar os 使用 sp for
原文地址:http://blog.csdn.net/jianhong1990/article/details/41209493