python,import pymysql,,# 创建连接,conn = pymysql.connect(host='localhost', port=3306, user='root', passwd='password', db='database_name', charset='utf8'),,# 创建游标,cursor = conn.cursor(),,# 执行SQL,并返回收影响行数,effect_row = cursor.execute("select * from table_name"),,# 执行SQL,并返回受影响的行数,effect_row = cursor.execute("update table_name set name='Tom' where id=1"),,# 提交事务:,conn.commit(),,# 关闭光标:,cursor.close(),,# 关闭连接:,conn.close(),
``