操作mysql数据库

1. 连接mysql

import pymysql
db = pymysql.connect(host='localhost', user='root', password='123456', port=3306, db='spiders')
cursor = db.cursor()
sql = 'select * from students;'
cursor.execute(sql)
cursor.close()
db.close()

posted on 2019-10-02 20:47  闪亮的金子  阅读(141)  评论(0编辑  收藏  举报