我是python pymysql的新手(我在Ruby之前使用mysql2gem),
我想从mysql表中获取key和value并执行一些操作:
例如:dbconnection = pymysql.connect(host=mysql_hostname, user=mysql_username, password=mysql_pass, db=mysql_schema, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor)
cursor = dbconnection.cursor()
_SQL = ("""
select * ...
""")
cursor.execute(_SQL)
result = cursor.fetchall()
for row in result:
print(row)
print("\n")
# How can I access each key and each value for example: STATUS is the value and 3 is the key
# I want to do something like this:
#'if the value of 'CAP' > 1: change the value of status where the ID key
# cursor.execute("UPDATE
输出:
^{pr2}$
谢谢