读取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())
相关推荐
say_fall几秒前
深入理解AVL树:平衡调整机制与性能优化实战
开发语言·数据结构·c++·学习
王仲肖2 分钟前
PostgreSQL 统计信息 — 完整总结与优化指南
数据库·postgresql
赖在沙发上的熊3 分钟前
Python数据序列
开发语言·python
有想法的py工程师3 分钟前
PostgreSQL vs PolarDB:Checkpoint 调优策略深度对比(高频 vs 低频)
大数据·数据库·postgresql
m0_377618236 分钟前
golang如何使用struct嵌套_golang struct结构体嵌套使用方法.txt
jvm·数据库·python
Hello--_--World9 分钟前
Js面试题目录表
开发语言·javascript·ecmascript
聆风吟º9 分钟前
【C标准库】深入理解C语言strcmp函数:字符串比较的核心用法
c语言·开发语言·库函数·strcmp
2301_8152795210 分钟前
Redis如何降低快照对CPU的影响_合理分配RDB执行时机避开业务高峰期
jvm·数据库·python
Fanfanaas15 分钟前
Linux 进程篇 (四)
linux·运维·服务器·开发语言·c++·学习
Sylvia-girl16 分钟前
C++中类与对象
开发语言·c++