Pyhton Sqlite3手机数据库

代码+结果

Code

python 复制代码
import sqlite3
conn=sqlite3.connect('test.db')
cs=conn.cursor()
create_tb_sql='''
        create table if not exists info(
        id int primary  key,
        name text,
        age int
        )
'''
cs.execute(create_tb_sql)

# cs.execute('insert into info(id,name,age) values(3,"dog_Senior",22)')
conn.commit()
# cs.execute('select name from info')
cs.execute('select * from info')
result= cs.fetchall()
print(result)

期间错误:

Python连接sqlite数据库,查询报错 sqlite3.OperationalError: no such table: userInfo

原因+解决措施:

1、数据库并没有建立该表。 【重新再建一个数据库】

2、程序没有找到该数据库中有该表。

【select name from sqlite_master where type='table' order by name; 】

查询的结果如果是 空,但是你可以点击数据表能看到数据,这就是数据库里面的表没有被检索到。

相关案例:

https://blog.csdn.net/m0_52103877/article/details/131093379

相关推荐
lambo mercy5 小时前
08_redis__集群 (Cluster)
数据库·redis·缓存
富贵儿9986 小时前
NL2SQL 实践手记 08:SQL 没报错,答案为什么不对——从失败复盘到 Workflow 修复
数据库·python·sql·ai·自然语言处理·langchain
Decay__8 小时前
PostgreSQL 运维自动化平台 —— 部署编排、监控、巡检、告警、工单闭环一体化
运维·数据库·sql·mysql·架构
0+11110 小时前
MySQL --基本查询
数据库·mysql
inferno10 小时前
十九、性能优化
数据库·sql·mysql
东莞市云毅网络有限公司12 小时前
用 Node 做收录快照的周对比:差集、阈值与告警
python·sqlite·自动化运维·geo·数据监测
底层玩家老张13 小时前
绿盟和金仓共建七个月的复盘:适配记录、两个场景、交付与人
数据库·嵌入式数据库·日志检索·产品适配·主备读写分离
Mojitocean13 小时前
主流数据库对比与业务场景选型指南
数据库
武子康13 小时前
GameEval第一轮先测什么:正常对照、已知故障与未知探索
大数据·数据库·人工智能