Spectrify
A simple yet powerful tool to move your data from Redshift to Redshift Spectrum.
Free software: MIT license
Documentation: https://spectrify.readthedocs.io.
Features
One-liners to:
Export a Redshift table to S3 (CSV)
Convert exported CSVs to Parquet files in parallel
Create the Spectrum table on your Redshift cluster
Perform all 3 steps in sequence, essentially “copying” a Redshift table Spectrum in one command.
S3 credentials are specified using boto3. See http://boto3.readthedocs.io/en/latest/guide/configuration.html
Redshift credentials are supplied via environment variables, command-line parameters, or interactive prompt.
Install
$ pip install psycopg2 # or psycopg2-binary
$ pip install spectrify
Command-line Usage
Export Redshift table my_table to a folder of CSV files on S3:
$ spectrify --host=example-url.redshift.aws.com --user=myuser --db=mydb export my_table \
's3://example-bucket/my_table'
Convert exported CSVs to Parquet:
$ spectrify --host=example-url.redshift.aws.com --user=myuser --db=mydb convert my_table \
's3://example-bucket/my_table'
Create Spectrum table from S3 folder:
$ spectrify --host=example-url.redshift.aws.com --user=myuser --db=mydb create_table \
's3://example-bucket/my_table' my_table my_spectrum_table
Transform Redshift table by performing all 3 steps in sequence:
$ spectrify --host=example-url.redshift.aws.com --user=myuser --db=mydb transform my_table \
's3://example-bucket/my_table'
Python Usage
Export to S3:
from spectrify.export import RedshiftDataExporter
RedshiftDataExporter(sa_engine, s3_config).export_to_csv('my_table')
Convert exported CSVs to Parquet:
from spectrify.convert import ConcurrentManifestConverter
from spectrify.utils.schema import SqlAlchemySchemaReader
sa_table = SqlAlchemySchemaReader(engine).get_table_schema('my_table')
ConcurrentManifestConverter(sa_table, s3_config).convert_manifest()
Create Spectrum table from S3 parquet folder:
from spectrify.create import SpectrumTableCreator
from spectrify.utils.schema import SqlAlchemySchemaReader
sa_table = SqlAlchemySchemaReader(engine).get_table_schema('my_table')
SpectrumTableCreator(sa_engine, dest_schema, dest_table_name, sa_table, s3_config).create()
Transform Redshift table by performing all 3 steps in sequence:
from spectrify.transform import TableTransformer
transformer = TableTransformer(engine, 'my_table', s3_config, dest_schema, dest_table_name)
transformer.transform()
Contribute
Contributions always welcome! Read our guide on contributing here: http://spectrify.readthedocs.io/en/latest/contributing.html
License
MIT License. Copyright (c) 2017, The Narrativ Company, Inc.
History
3.1.0 (2020-01-18)
Remove psycopg2 requirement (allows use of either psycopg2 or psycopg2-binary)
3.0.1 (2019-11-26)
Fix changelog
3.0.0 (2019-11-26)
Backwards incompatible changes:
Add REGION parameter to UNLOAD operations
Bugfix: Correctly construct path for S3 bucket in “create-table” command
Other Changes:
Support for obtaining credentials with AWS session token
Upgrade to pytest v4.6.6
Fix Flake8 errors
2.0.0 (2019-03-09)
Default to 256MB files
Flag for unicode support on Python 2.7 (performance implications)
Drop support for Python 3.4
Support for additional CSV format parameters
Support for REAL data type
1.0.1 (2018-07-12)
Loosen version requirement for PyArrow
Add example script
Update documentation
1.0.0 (2018-04-20)
Move functionality into classes to make customizing behavior easier
Add support for DATE columns
Add support for DECIMAL/NUMERIC columns
Upgrade to pyarrow v0.9.0
0.4.1 (2018-03-25)
Fix exception when source table is not in schema public
0.4.0 (2018-02-25)
Upgrade to pyarrow v0.8.0
Verify Redshift column types are supported before attempting conversion
Bugfix: Properly clean up multiprocessing.pool resource
0.3.0 (2017-10-30)
Support 16- and 32-bit integers
Packaging updates
0.2.1 (2017-09-27)
Fix Readme
0.2.0 (2017-09-27)
First release on PyPI.
0.1.0 (2017-09-13)
Didn’t even make it to PyPI.
Metadata
Release files for spectrify 3.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| spectrify-3.1.0.tar.gz | 28.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| spectrify-3.1.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 46.6 kB
Release files / spectrify-3.1.0.tar.gz
| Download URL | spectrify-3.1.0.tar.gz |
|---|---|
| Size | 28.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7121d745fdea8d5a4941664b425a4da08d52f63c7247d3aa364e2ecb98050cf
|
|
BLAKE2b-256 checksum How to use checksums |
826049d6f91b7568d60b182d246dadac4b10fdab12a09fafe2b8debbb093b8fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/2.7.15
|
Release files / spectrify-3.1.0-py2.py3-none-any.whl
| Download URL | spectrify-3.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 17.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
26d6631dd5d81499da0630159353ec1d19bb797cb1773a8318b410c864e31fd9
|
|
BLAKE2b-256 checksum How to use checksums |
0cd37de2a0b55f10ae2cb469ca347e90f6382773f67108982769081cfec2d435
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/2.7.15
|
Security for spectrify 3.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.