读取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())
相关推荐
ytttr8738 小时前
C++ LZW 文件压缩算法实现
开发语言·c++
Elastic 中国社区官方博客8 小时前
使用 Elastic Observability 和 MCP 的 Agentic 驱动 Kubernetes 调查
数据库·elasticsearch·搜索引擎·云原生·容器·kubernetes·全文检索
jr-create(•̀⌄•́)8 小时前
简单视频编辑tools
python·ffmpeg
袁袁袁袁满8 小时前
亮数据SERP API实现搜索引擎实时数据采集
爬虫·python·网络爬虫·爬山算法
1candobetter8 小时前
JAVA后端开发——多模块项目重命名体系解析
java·开发语言·intellij-idea
阿正的梦工坊8 小时前
DOCKER_DATABASE_URL 逐段解析:部署时候的信息解析
数据库·docker·容器
citi8 小时前
OpenViking 本地搭建指南
开发语言·python·ai
彭于晏Yan8 小时前
Spring Boot + WebSocket 实现单聊已读未读(四)
spring boot·python·websocket
AI玫瑰助手8 小时前
Python基础:列表的切片与嵌套列表使用技巧
android·开发语言·python
倒流时光三十年8 小时前
PostgreSQL 大表字段扩长度 -- 会不会锁表?
数据库·postgresql