sql语句2

python连接数据库

导入模块 from pymysql import *

1练接数据库

conn=connect(host="localhost",port=3306,datdabase="数据库名",user="root",password="mysql",charset="utf8")

2 设置游标

csl=conn.curcor()

3执行sql语句

csl.execute(sql语句)

4获取结果

结果=csl.fetchall()

5关闭

csl.close()

conn.close()



猜你喜欢

转载自blog.csdn.net/weixin_42020284/article/details/80155443