使用MySQL

安装MySQL驱动

使用vpn

$ pip install mysql-connector-python --allow-external mysql-connector-python
import mysql.connector

conn = mysql.connector.connect(user='root', password='nana123', database='test')
cursor = conn.cursor() cursor.execute('create table user (id varchar(20) primary key, name varchar(20))')
cursor.execute('insert into user (id, name) values (%s, %s)', ['', 'Michael'])
cursor.rowcount
conn.commit()
cursor.close() cursor = conn.cursor()
cursor.execute('select * from user where id = %s', [''])
values = cursor.fetchall()
print(values) cursor.close()
conn.close()
上一篇:linux ll 命令各列的含义


下一篇:获取week of year的小程序