读取sqlite数据库的2种方式

0x00 背景

做项目需要用到sqlite数据库,这里提供2种方式查询数据。

0x01 命令行读取

yum install sqlite-devel 安装数据库。

访问某个数据库

sqlite3 xxx.db

查看tables

.tables

查询表(这里的sql语法和mysql差不多)

select * from history order by seq desc limit 5;

0x02 python程序读取

python 复制代码
import sqlite3
conn = sqlite3.connect('xxx.db')
c = conn.cursor()
c.execute("""select * from history order by seq desc limit 100""")
print(c.fetchall())
c.execute("""select * from config limit 100""")
print(c.fetchall())
相关推荐
June bug11 分钟前
(#字符串处理)字符串中第一个不重复的字母
python·leetcode·面试·职场和发展·跳槽
ggabb21 分钟前
大模型时代:汉语凭什么是AI界的“天选语言”?
sqlite
json{shen:"jing"}23 分钟前
1. 两数之和
前端·javascript·数据库
techdashen28 分钟前
Rust OnceCell 深度解析:延迟初始化的优雅解决方案
开发语言·oracle·rust
github.com/starRTC33 分钟前
Claude Code中英文系列教程19:使用subagent子代理与创建自定义子代理【重要】
前端·javascript·数据库
少控科技35 分钟前
QT新手日记033
开发语言·qt
lixzest1 小时前
PyTorch基础知识简述
人工智能·pytorch·python
Anastasiozzzz1 小时前
Redis的键过期是如何删除的?【面试高频】
java·数据库·redis·缓存·面试
飞Link1 小时前
深度学习里程碑:ResNet(残差网络)从理论到实战全解析
人工智能·python·深度学习
北海屿鹿1 小时前
【MySQL】内置函数
android·数据库·mysql