读取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())
相关推荐
cany100014 小时前
C++ - 智能指针
开发语言·c++
Old Uncle Tom14 小时前
提示词编写规范
数据库·算法
l1t14 小时前
DeepSeek总结的Postgres 扩展天花板:当一个实例试图包揽一切时
数据库·postgresql
我要升天!14 小时前
C语言连接 MySQL:libmysqlclient 获取方式详解
c语言·开发语言·数据库·mysql·adb
a11177614 小时前
jetpack5.0对应版本的torch和torchvision
python·开源·torch
Where-14 小时前
LangChain核心组件-Tool
python·langchain
angushine14 小时前
Python常用方法
开发语言·前端·python
潜创微科技14 小时前
CH9245:双 Type‑C 转 PD 芯片方案,便携显示与拓展坞的理想选择
c语言·开发语言
【 】42314 小时前
pyhon相对导入
开发语言·python
小同志0014 小时前
IoC 详解
java·开发语言