# python + pymysql 创建数据库 import pymysql# 创建连接conn = pymysql.connect(host='localhost',user='root',password='123456',charset='utf8mb4')# 创建游标cursor = conn.cursor()# 创建数据库的sql(如果数据库存在就不创建,防止异常)sql = "CREATE DATABASE IF NOT EXISTS db_name" # 执行创建数据库的sqlcursor.execute(sql)# 创建表sql_2 = '''CREATE TABLE `employee` (`id` INT NOT NULL AUTO_INCREMENT,`topic` INT ,`ptid` INT NOT NULL,`level` INT NOT NULL,`time` TIME,`consume` INT NOT NULL,`err` INT NOT NULL,`points` INT NOT NULL,`gid` INT NOT NULL,PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;'''cursor.execute(sql_2)
1200字范文,内容丰富有趣,写作的好帮手!