Sté*_*ane 1 sql sqlite database-schema python-3.x
我使用python创建了一些sqlite表架构。
当我使用sqlite3客户端并发出.schema命令时,我可以看到输出已预先格式化,如用作该executescript()函数参数的SQL源文件中所示。
有什么方法可以用来格式化.schema命令的输出?
在最新版本(3.13.0)中,您拥有
>sqlite3 test.dat
SQLite version 3.13.0 2016-05-18 10:57:30
sqlite> create table test ( a integer,b integer, c integer,d float,e text, f primary key);
sqlite> .schema
CREATE TABLE test ( a integer,b integer, c integer,d float,e text, f primary key);
sqlite> .schema --indent
CREATE TABLE test(
a integer,
b integer,
c integer,
d float,
e text,
f primary key
);
Run Code Online (Sandbox Code Playgroud)
我也在为此寻找解决方案。
命令:
> .header on
> .mode column
> pragma table_info('table_name');
Run Code Online (Sandbox Code Playgroud)
给出输出:
cid name type notnull dflt_value pk
---------- ---------- ----------- ---------- ---------- ----------
0 id varchar(24) 1 1
1 uuid varchar(36) 1 0
2 title varchar(200 1 0
3 slug varchar(191 1 0
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
496 次 |
| 最近记录: |