本文介紹了使用 Python sqlite3 API 的表列表、數據庫模式、轉儲等的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
出于某種原因,我找不到獲得 sqlite 交互式 shell 命令等價物的方法:
For some reason I can't find a way to get the equivalents of sqlite's interactive shell commands:
.tables
.dump
使用 Python sqlite3 API.
using the Python sqlite3 API.
有這樣的嗎?
推薦答案
您可以通過查詢 SQLITE_MASTER 表來獲取表列表和模式:
You can fetch the list of tables and schemata by querying the SQLITE_MASTER table:
sqlite> .tab
job snmptarget t1 t2 t3
sqlite> select name from sqlite_master where type = 'table';
job
t1
t2
snmptarget
t3
sqlite> .schema job
CREATE TABLE job (
id INTEGER PRIMARY KEY,
data VARCHAR
);
sqlite> select sql from sqlite_master where type = 'table' and name = 'job';
CREATE TABLE job (
id INTEGER PRIMARY KEY,
data VARCHAR
)
這篇關于使用 Python sqlite3 API 的表列表、數據庫模式、轉儲等的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!