python连接数据库
import timefrom sys import pathpath.append(r‘C:\Users\Administrator\ceshi1111\Lib\site-packages\pymysql‘)import pymysqlfrom pymysql import *db = pymysql.connect(‘192.168.137.9‘,"root","123123","mysql") #:调用pymysql.connect方法 并输入数据库的信息cursor = db.cursor() #:调用db中的cursor类cursor.execute("insert into test1 values(‘1‘);") #:sql语句db.commit() #:提交事务date = cursor.fetchall()db.close() #:关闭连接