本文介紹了使用 Python sqlite3 API 的表列表、數(shù)據(jù)庫(kù)模式、轉(zhuǎn)儲(chǔ)等的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
出于某種原因,我找不到獲得 sqlite 交互式 shell 命令等價(jià)物的方法:
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.
有這樣的嗎?
推薦答案
您可以通過(guò)查詢 SQLITE_MASTER 表來(lái)獲取表列表和模式:
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
)
這篇關(guān)于使用 Python sqlite3 API 的表列表、數(shù)據(jù)庫(kù)模式、轉(zhuǎn)儲(chǔ)等的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!