Skip to main content

Inspect database schema, tables and columns and returns a metadata object

Project description

dbmeta v0.0.11

Database metadata extractor

Generate a Metadata object containing information about the database.

Install

pip install dbmeta

Use

import dbmeta

db_type = 'postgres'
db_url = 'postgres://postgres:postgres@localhost:5432'
metadata = dbmeta.gen_metadata(db_type, db_url)

Excluding schema or tables

Postgres system tables and schema are already excluded from the introspection. To exclude other tables or schema use the exclude class

from dbmeta import exclude

exclude.schema = ["hdb_catalog"]
exclude.tables = ["migrations"]

...

Classes

Metadata

class Metadata:
    schema: List[Schema]
    tables: List[Table]
    columns: List[Column]
    user_defined: List[UserDefined]

Schema

class Schema(DatabaseItem):
    catalog_name: str
    schema_name: str
    schema_owner: str
    tables: List[Table]

Table

class Table(DatabaseItem):
    table_catalog: str
    table_schema: str
    table_name: str
    table_type: str
    columns: List[Column]

Column

class Column(DatabaseItem):
    udt_name: str
    table_catalog: str
    table_schema: str
    table_name: str
    column_name: str
    ordinal_position: int
    column_default: str | None
    is_nullable: Literal["YES"] | Literal["NO"]
    data_type: str
    character_maximum_length: int | None
    is_updatable: bool

User Defined Types

class UserDefined(DatabaseItem):
    schema: str
    name: str
    internal_name: str
    elements: List[str | int]

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

dbmeta-0.0.12.tar.gz (7.9 kB view hashes)

Uploaded Source

Built Distribution

dbmeta-0.0.12-py2.py3-none-any.whl (6.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