美文网首页
Pymysql基本用法

Pymysql基本用法

作者: Ancestor楠 | 来源:发表于2020-02-20 21:35 被阅读0次

-- 取数据

count = cursor.execute("select * from goods;")

print("查询到%d条数据"% count)

print(cursor.fetchone()) #取一条数据

print(cursor.fetchmany()) #取一条

print(cursor.fetchmany(3)) # 传几取几条

print(cursor.fetchall()) #取所有

print(cursor.fetchall())#取所有

取两次所有的结果

line_content = cursor.fetchone()

print(line_content)(显示元组())

-- 索引

print(line_content[0])

print(line_content[1])

print(line_content[2])

-- 循环line_content:

for temp in line_content:

print(temp)

--  fetchmany循环

lines = cursor.fetchmany(5)

for temp in lines:

print(temp)

# 关闭Cursor对象

cursor.close() #关闭游标

conn.close()

print(cursor.fetchone(),'-------------->') 

count = cursor.execute("select * from goods;")

相关文章

  • Pymysql基本用法

    -- 取数据 count = cursor.execute("select * from goods;") pri...

  • pymysql的用法

    一、首先要安装MySQL,我安装的mysq5.7的;具体安装步骤可以自行百度,或者参考这个win10安装MYSQL...

  • pymysql connect 模块

    connections 模块 类:Connection 用法:执行pymysql.connect()得到。而不是构...

  • pymysql基本操作

    链接数据库 conn = pymysql.connect(host=“你的数据库地址”,user=“用户名”,pa...

  • pymysql的常见用法

    从mysql 中导出数据: 连接池: 相比上一种方式,连接池能提高性能,主要表现在: 1.创建新连接的时候,可以从...

  • MySQL(四)

    与Python交互 使用pymysql来代替MySQLdb模块,它们用法非常相似。 Connection对象 用于...

  • PyMySQL模块基本使用

    1、安装最新版本pymysql+查看模块依赖信息: 2、创建MySQL的连接: 3、创建Curs...

  • 10.PyMySQL模块

    PyMySQL模块 安装PyMySQL模块pip install pymysql PyMySQL查询数据impor...

  • 定时器

    setTimeout和clearTimeout基本用法 setInterval和clearInterval基本用法...

  • 2019-11-16

    E战到底DAY14 SUMIF和SUMIFS函数 一.基本用法 SUMIF基本用法 SUMIFS基本用法 SUMI...

网友评论

      本文标题:Pymysql基本用法

      本文链接:https://www.haomeiwen.com/subject/vlmfqhtx.html