mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 01:14:31 +02:00
db.schema and 'sqlite-utils schema' command, closes #268
This commit is contained in:
parent
9696abfabf
commit
0d2e4f49f3
6 changed files with 90 additions and 2 deletions
|
|
@ -297,6 +297,21 @@ If the record does not exist a ``NotFoundError`` will be raised:
|
|||
except NotFoundError:
|
||||
print("Dog not found")
|
||||
|
||||
.. _python_api_schema:
|
||||
|
||||
Showing the schema
|
||||
==================
|
||||
|
||||
The ``db.schema`` property returns the full SQL schema for the database as a string::
|
||||
|
||||
>>> db = sqlite_utils.Database("dogs.db")
|
||||
>>> print(db.schema)
|
||||
>>> print(db.schema)
|
||||
CREATE TABLE "dogs" (
|
||||
[id] INTEGER PRIMARY KEY,
|
||||
[name] TEXT
|
||||
);
|
||||
|
||||
.. _python_api_creating_tables:
|
||||
|
||||
Creating tables
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue