Skip to main content

sqliteschema is a python library to dump table schema of a SQLite database file.

Project description

sqliteschema

https://badge.fury.io/py/sqliteschema.svg https://img.shields.io/pypi/pyversions/sqliteschema.svg https://img.shields.io/travis/thombashi/sqliteschema/master.svg?label=Linux https://img.shields.io/appveyor/ci/thombashi/sqliteschema/master.svg?label=Windows https://coveralls.io/repos/github/thombashi/sqliteschema/badge.svg?branch=master

Summary

Python library to dump table schema of a SQLite database file.

Installation

pip install sqlitestructure

Usage

for verbosity_level in range(6):
    print("===== verbosity level {} =====".format(verbosity_level))
    extractor = sqliteschema.SqliteSchemaExtractor(db_path, verbosity_level)
    print(extractor.dumps())
===== verbosity level 0 =====
sampletable0
sampletable1
sampletable2

===== verbosity level 1 =====
sampletable0 ("attr_a", "attr_b")
sampletable1 (foo, bar, hoge)
sampletable2 (abc, efg)

===== verbosity level 2 =====
sampletable0 ("attr_a" INTEGER, "attr_b" INTEGER)
sampletable1 (foo INTEGER, bar REAL, hoge TEXT)
sampletable2 (abc INTEGER, efg REAL)

===== verbosity level 3 =====
sampletable0 ("attr_a" INTEGER, "attr_b" INTEGER)
sampletable1 (foo INTEGER, bar REAL, hoge TEXT)
sampletable2 (abc INTEGER PRIMARY KEY, efg REAL NOT NULL)

===== verbosity level 4 =====
sampletable0 (
    "attr_a" INTEGER,
    "attr_b" INTEGER
)
sampletable1 (
    foo INTEGER,
    bar REAL,
    hoge TEXT
)
sampletable2 (
    abc INTEGER PRIMARY KEY,
    efg REAL NOT NULL
)

===== verbosity level 5 =====
sampletable0 (
    "attr_a" INTEGER,
    "attr_b" INTEGER
)

sampletable1 (
    foo INTEGER,
    bar REAL,
    hoge TEXT
)
    CREATE INDEX sampletable1_foo_index ON sampletable1('foo')
    CREATE INDEX sampletable1_hoge_index ON sampletable1('hoge')
sampletable2 (
    abc INTEGER PRIMARY KEY,
    efg REAL NOT NULL
)

Full example can be found at examples/get_table_schema.py

Dependencies

Python 2.7+ or 3.3+

Test dependencies

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqliteschema-0.6.0.tar.gz (9.6 kB view hashes)

Uploaded Source

Built Distribution

sqliteschema-0.6.0-py2.py3-none-any.whl (9.7 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page