读取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())
相关推荐
阿米亚波12 小时前
【C++ STL】std::unordered_multimap
开发语言·数据结构·c++·笔记·stl
天使day12 小时前
FastAPI快速入门
python·fastapi
databook12 小时前
用相关性分析消除“冗余特征”
python·机器学习·scikit-learn
林焱RPA12 小时前
影刀RPA200篇纪念版:最实用的20个自动化场景大盘点
数据库
名字还没想好☜12 小时前
Go 的 time.After 在 select 循环里内存泄漏:定时器堆积原理与 timer.Reset 正确姿势
java·数据库·golang·go·goroutine
SomeB1oody13 小时前
【RustyML入门】1.0. 快速上手
开发语言·后端·机器学习·rust·教程
狗凯之家源码网13 小时前
短剧系统搭建实战:源码功能与商业变现效果全景展示
开发语言·php
幻想时空13 小时前
地图数据采集
python
梦想不只是梦与想13 小时前
Python 中的类型判断方法
python·type·isinstance
alphaTao14 小时前
LeetCode 每日一题 2026/7/27-2026/8/2
python·算法·leetcode