读取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())
相关推荐
wgc2k7 分钟前
Nest.js 基础-8-Hello,NestJS
开发语言·javascript·ecmascript
拾贰_C10 分钟前
【python | installation 】python 安装 | Windows | 命令使用
linux·数据库·ubuntu
CTA量化套保11 分钟前
一个账户跑多个期货策略:仓位与报单隔离思路
python·区块链
机汇五金_12 分钟前
影响交换机箱体使用寿命的几个关键因素
运维·服务器·网络·python
子午14 分钟前
基于DeepSeek的酒店客房管理系统~Python+DeepSeek智能问答+Vue3+Web网站系统
开发语言·前端·python
ghie909014 分钟前
基于 MATLAB 的序贯蒙特卡洛概率假设密度多目标跟踪实现
开发语言·matlab·目标跟踪
我命由我1234516 分钟前
Java 开发 - Jar 包与 War 包
java·开发语言·java-ee·intellij-idea·jar·idea·intellij idea
峰上踏雪17 分钟前
Windows 下最推荐的 Qt + VS2026 + CMake 开发方案
开发语言·windows·qt
编程大师哥19 分钟前
最高效的 IO 并发方案
linux·网络·python
Hello:CodeWorld20 分钟前
Dify 从入门到实战:部署、模型对接与企业级 AI 应用开发全教程
人工智能·python·架构·ai编程