读取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())
相关推荐
一个处女座的程序猿O(∩_∩)O15 分钟前
Python异常处理完全指南:KeyError、TypeError、ValueError深度解析
开发语言·python
暮色妖娆丶15 分钟前
Spring 源码分析 事务管理的实现原理(下)
数据库·spring boot·spring
暮色妖娆丶16 分钟前
Spring 源码分析 事务管理的实现原理(上)
数据库·spring boot·spring
was17217 分钟前
使用 Python 脚本一键上传图片到兰空图床并自动复制链接
python·api上传·自建图床·一键脚本
LaughingZhu30 分钟前
Product Hunt 每日热榜 | 2026-02-18
大数据·数据库·人工智能·经验分享·搜索引擎
好学且牛逼的马30 分钟前
从“Oak”到“虚拟线程”:JDK 1.0到25演进全记录与核心知识点详解a
java·开发语言·python
shangjian0071 小时前
Python基础-环境安装-Anaconda配置虚拟环境
开发语言·python
codeJinger1 小时前
【Python】函数
开发语言·python
是吕先森1 小时前
mysql基础
数据库·mysql·oracle
geovindu2 小时前
python: Command Pattern
开发语言·python·命令模式