• 周二. 6月 25th, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

python—-pymysql

admin

11月 28, 2021

1. 导入pymysql

  import pymysql

2. 连接数据库

  conn=pymysql.connect(host=’localhost’,user=’root’,password=’root’,database=’ere’,charset=’utf8′) 

3. 获取操作游标

  cur=conn.cursor()

4. 执行sql语句

    插入记录:sta=cur.execute(“insert 语句”)     执行成功后sta值为1。更新、删除语句与此类似。

  查询记录:cur.execute(“select语句”)         执行成功后cur变量中保存了查询结果记录集,然后再用循环打印结果

  resList = cur.fetchall()

5.关闭数据库

  cur.close();

    conn.close();

 

《python—-pymysql》有2个想法
  1. Wow, marvelous weblog format! How long have you been running a blog for?
    you made running a blog glance easy. The total look of your
    site is magnificent, as smartly as the content material!
    You can see similar here sklep

  2. Wow, superb blog format! How lengthy have you been blogging for?
    you make running a blog look easy. The entire look of your website is fantastic, as well as the content
    material! You can see similar here dobry sklep

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注