读取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())
相关推荐
高梦轩2 小时前
MySQL高可用
android·运维·数据库
ggabb3 小时前
美国大力投资AI的原因分析
sqlite
紫金修道4 小时前
【DeepAgent】概述
开发语言·数据库·python
Via_Neo4 小时前
JAVA中以2为底的对数表示方式
java·开发语言
书到用时方恨少!4 小时前
Python multiprocessing 使用指南:突破 GIL 束缚的并行计算利器
开发语言·python·并行·多进程
cch89185 小时前
PHP五大后台框架横向对比
开发语言·php
孟章豪5 小时前
《SQL拼接 vs 参数化,为什么公司禁止拼接SQL?(附真实案例)》
服务器·数据库·sql
荒川之神5 小时前
ORACLE LEVEL函数练习
数据库·oracle
Warson_L5 小时前
Python 常用内置标准库
python
·云扬·5 小时前
【MySQL】实战:用pt-table-sync修复主从数据一致性问题
数据库·mysql·ffmpeg