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

相关推荐
Shely201721 分钟前
MySQL数据表管理
数据库·mysql
爬山算法28 分钟前
MongoDB(80)如何在MongoDB中使用多文档事务?
数据库·python·mongodb
APguantou34 分钟前
NCRE-三级数据库技术-第2章-需求分析
数据库·需求分析
寂夜了无痕1 小时前
MySQL 主从延迟全链路根因诊断与破局法则
数据库·mysql·mysql主从延迟
爱丽_1 小时前
分页为什么越翻越慢:offset 陷阱、seek 分页与索引排序优化
数据库·mysql
APguantou1 小时前
NCRE-三级数据库技术-第12章-备份与数据库恢复
数据库·sqlserver
Bat U1 小时前
MySQL数据库|表设计+新增+分组查询
数据库·mysql
麦聪聊数据2 小时前
企业数据流通与敏捷API交付实战(五):异构数据跨库联邦与零代码发布
数据库·sql·低代码·restful
Elastic 中国社区官方博客2 小时前
当 TSDS 遇到 ILM:设计不会拒绝延迟数据的时间序列数据流
大数据·运维·数据库·elasticsearch·搜索引擎·logstash
Omics Pro2 小时前
虚拟细胞:开启HIV/AIDS治疗新纪元的关键?
大数据·数据库·人工智能·深度学习·算法·机器学习·计算机视觉