读取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())
相关推荐
小白开始进步1 天前
OpenCV图像滤波:Python实战指南
人工智能·python·opencv
TG:@yunlaoda360 云老大1 天前
华为云国际站代理商Image主要有什么作用呢?
数据库·游戏·华为云
Aevget1 天前
Python开发利器PyCharm v2025.3全新发布——支持主动数据探索
开发语言·ide·python·pycharm
znhy_231 天前
day44打卡
python
子夜江寒1 天前
PyTorch:基于MNIST的手写数字识别
pytorch·python·深度学习
island13141 天前
PyTorch 2.0 核心技术深度解析torch.compile 从原理到实践
人工智能·pytorch·python
SadSunset1 天前
(35)使用Spring的AOP
java·数据库·spring
mangge081 天前
批量把word转图片再转pdf,防止文字被复制
开发语言
小c君tt1 天前
QT中treewidget中右键添加QAction方法
开发语言·qt
HUST1 天前
C 语言 第九讲:函数递归
c语言·开发语言·数据结构·算法·c#