读取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())
相关推荐
yuzhiboyouye10 小时前
内连接,左连接,右连接怎么区别开来?
数据库
明月_清风10 小时前
FastAPI 从入门到实战:3 分钟构建高性能异步 API
后端·python·fastapi
笨拙的老猴子10 小时前
[特殊字符] Java GC机制详解:G1、ZGC、Shenandoah全面解析与版本演进对比
java·开发语言
bellus-10 小时前
ubuntu26测试win10的ollama大模型性能
python
水木流年追梦10 小时前
大模型入门-Reward 奖励模型训练
开发语言·python·算法·leetcode·正则表达式
JavaWeb学起来10 小时前
Python学习教程(六)数据结构List(列表)
数据结构·python·python基础·python教程
铭毅天下10 小时前
Easysearch 版本进化全图——从 ES 国产替代到 AI Native 搜索数据库
大数据·数据库·人工智能·elasticsearch·搜索引擎
liuyunshengsir10 小时前
PyTorch 动态量化(Dynamic Quantization)
人工智能·pytorch·python
muddjsv10 小时前
SQL 最常用技能详解与实战示例
数据库·sql·mysql
电子云与长程纠缠10 小时前
UE5制作六边形包裹球体效果
开发语言·python·ue5