python连接mysql

import pymysql

conn = pymysql.connect(host='localhost',user='root',passwd='root',db='test',port=3306,charset='utf8')

cur = conn.cursor()

sql = '''create table if not exists fish

    (date1 char(12) primary key not null,

    name char(10) not null,

    nums int not null,

    price decimal(10,2) not null);'''

conn.commit()

 

posted @ 2020-11-30 22:39  kaiser_yinkai  阅读(61)  评论(0)    收藏  举报