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

相关推荐
IT龟苓膏3 小时前
Redis 数据类型底层原理:SDS、quicklist、intset、skiplist、Bitmap、HyperLogLog 一篇讲清
数据库·redis·skiplist
流星白龙3 小时前
【MySQL高阶】19.变更缓冲区,自适应哈希索引,日志缓冲区
数据库·windows·mysql
晴天¥3 小时前
Oracle中的监听配置与管理(动态、静态监听配置对比以及listener.ora和tnsnames.ora)
数据库·oracle
瀚高PG实验室4 小时前
python连接HGDB超时
数据库·瀚高数据库·highgo
jnrjian4 小时前
ddl_lock_timeout 设置 read only table 通过view 实现细粒度依赖
sql·oracle
闪电悠米5 小时前
黑马点评-Redisson-01_why_redisson
java·服务器·网络·数据库·缓存·wpf
Counter-Strike大牛5 小时前
SpringBoot2.7.10+MyBatisPlus实现MySQL+DM双数据库切换
数据库·mysql
dllxhcjla6 小时前
Redis
数据库·redis·缓存
睡不醒男孩0308236 小时前
数据库高可用运维实操指南:基于CLup的PostgreSQL生产环境自动化管理
运维·数据库·postgresql
神仙别闹6 小时前
基于Python + SQL server 实现(GUI)原神圣遗物管理与角色数值模拟系统
java·数据库·python