python链接mysql

import pymysql

conn = pymysql.connect(host="localhost", port=3366, user="root",  password="123456", database="bnx", charset="utf8")

cursor = conn.cursor()

sql = "select * from cells"
cursor.execute(sql)
result = cursor.fetchall()
for row in result:
    print(row)
cursor.close()
conn.close()

怎么在Python中操作MySQL数据库?
Python 使用mysql-connector连接数据库实现基本的CRUD操作

你可能感兴趣的:(python,mysql)