Skip to main content

Auto-generate Redshift schemas from flat files

Project description

Redshift Auto Schema

Redshift Auto Schema is a Python library that takes a delimited flat file or parquet file as input, parses it, and provides a variety of functions that allow for the creation and validation of tables within Amazon Redshift. For each field, the appropriate Redshift data type is inferred from the contents of the file.

Installation

Use the package manager pip to install Redshift Auto Schema.

pip install redshift-auto-schema

Usage

from redshift_auto_schema import RedshiftAutoSchema
import psycopg2 as pg

redshift_conn = pg.connect()

new_table = RedshiftAutoSchema(file='sample_file.parquet',
                               schema='test_schema',
                               table='test_table',
                               conn=redshift_conn)

if not new_table.check_table_existence():
    ddl = new_table.generate_table_ddl()

    with redshift_conn.cursor() as redshift_cursor:
        redshift_cursor.execute(ddl)

Methods

NAME DESCRIPTION
check_schema_existence Checks Redshift for the existence of a schema.
generate_schema_ddl Returns a SQL statement that creates a Redshift schema.
generate_schema_permissions Returns a SQL statement that grants schema usage to the default group.
check_table_existence Checks Redshift for the existence of a table.
generate_table_ddl Returns a SQL statement that creates a Redshift table.
generate_table_permissions Returns a SQL statement that grants table read access to the default group.
evaluate_table_ddl_diffs Returns a dataframe containing differences between generated and existing table DDL.

Contributing

Pull requests are welcome.

License

Apache License 2.0

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

redshift-auto-schema-0.1.2.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

redshift_auto_schema-0.1.2-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file redshift-auto-schema-0.1.2.tar.gz.

File metadata

  • Download URL: redshift-auto-schema-0.1.2.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for redshift-auto-schema-0.1.2.tar.gz
Algorithm Hash digest
SHA256 bdf0e125e270a6e69c2abef50c1ae5c0833b6fd58da9d0bb76f297c55a63500b
MD5 bfdf7e06d553135611f722fe51a3f837
BLAKE2b-256 388fcf2aef7b7a04d6cd5d5430f2a56684d1dce8a2cebb119608d0fb38c1f0a6

See more details on using hashes here.

File details

Details for the file redshift_auto_schema-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: redshift_auto_schema-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for redshift_auto_schema-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f1fbb4fbf0969d7e85004474ff4849dccad65c4b43066cb845eeef115fc6d903
MD5 b3dbcc21f22c701161bb4f375fac2832
BLAKE2b-256 f40052c8f22341d19eb9841420a784222e4d78256af6fce1991b57c7b6e81b76

See more details on using hashes here.

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