import pymysql.cursors #链接数据库 conn = pymysql.Connect(host="localhost", user="root", password="123", charset="utf8") print(conn) cursor = conn.cursor()## 创建游标,通过游标执行SQL语句 #执行SQL语句 cursor.execute("create database pythondb ") #关闭链接 cursor.close() conn.close() print("ok")