读取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())
相关推荐
無限進步D1 天前
Java 运行原理
java·开发语言·入门
是苏浙1 天前
JDK17新增特性
java·开发语言
Mike117.1 天前
GBase 8a 日期边界写法和时间窗口取数偏差
数据库
花酒锄作田1 天前
企业微信机器人与 DeepAgents 集成实践
python·mcp·deepagents
SPC的存折1 天前
1、Redis数据库基础
linux·运维·服务器·数据库·redis·缓存
阿里加多1 天前
第 4 章:Go 线程模型——GMP 深度解析
java·开发语言·后端·golang
likerhood1 天前
java中`==`和`.equals()`区别
java·开发语言·python
qq_283720051 天前
Python Celery + FastAPI + Vue 全栈异步任务实战
vue.js·python·fastapi
2401_885885041 天前
营销推广短信接口集成:结合营销策略实现的API接口动态变量填充方案
前端·python
zs宝来了1 天前
AQS详解
java·开发语言·jvm