Amazon Redshift Dialect for sqlalchemy
Amazon Redshift dialect for SQLAlchemy.
The package is available on PyPI::
pip install sqlalchemy-redshift
.. warning::
This dialect requires either ``redshift_connector`` or ``psycopg2``
to work properly. It does not provide
it as required, but relies on you to select the distribution you need:
* psycopg2 - standard distribution of psycopg2, requires compilation so few system dependencies are required for it
* psycopg2-binary - already compiled distribution (no system dependencies are required)
* psycopg2cffi - pypy compatible version
See `Psycopg2's binary install docs <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>`_
for more context on choosing a distribution.
The DSN format is similar to that of regular Postgres::
>>> import sqlalchemy as sa
>>> sa.create_engine('redshift+psycopg2://username@host.amazonaws.com:5439/database')
Engine(redshift+psycopg2://username@host.amazonaws.com:5439/database)
See the RedshiftDDLCompiler documentation <https://sqlalchemy-redshift.readthedocs.org/en/latest/ddl-compiler.html>_
for details on Redshift-specific features the dialect supports.
Tests are ran via tox and can be run with the following command::
$ tox
However, this will not run integration tests unless the following environment variables are set:
Note that the IAM role specified will need to be associated with
redshift cluster and have the correct permissions to create databases
and tables as well drop them. Exporting these environment variables in
your shell and running tox will run the integration tests against
a real redshift instance. Practice caution when running these tests
against a production instance.
Project CI is built using AWS CodePipeline and CloudFormation. Please see the ci/ folder and included README.txt
for details on how to spin up the project's CI.
To perform a release, you will need to be an admin for the project on GitHub and on PyPI. Contact the maintainers if you need that access.
You will need to have a ~/.pypirc with your PyPI credentials and
also the following settings::
[zest.releaser]
create-wheels = yes
To perform a release, run the following::
python -m venv ~/.virtualenvs/dist
workon dist
pip install -U pip setuptools wheel
pip install -U tox zest.releaser
fullrelease  # follow prompts, use semver ish with versions.
The releaser will handle updating version data on the package and in CHANGES.rst along with tagging the repo and uploading to PyPI.
Pull #266 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/266>_)Pull #276 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/276>_)Pull #277 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/277>_)Pull #263 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/263>_)Pull #259 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/259>_)Pull #257 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/257>_)Pull #246 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/246>_)Pull #249 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/249>_)Pull #250 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/250>_)Pull #255 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/255>_)Pull #242 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/242>_)>=3.4
(Pull #234 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/234>_)Pull #235 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/235>_)Pull #237 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/237>_)Pull #232 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/232>_)Pull #231 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/231>_)Pull #229 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/229>_)Pull #228 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/228>_)Pull #223 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/223>_)Pull #221 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/221>_)here <https://docs.aws.amazon.com/redshift/latest/mgmt/authorizing-redshift-service.html#authorizing-redshift-service-chaining-roles>_.Pull #204 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/204>_)Pull #206 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/206>_)Issue #195 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/195>_)Issue #202 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/202>_)Issue #199 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/199>_)Issue #191 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/issues/191>_)Issue #189 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/issues/189>_)UNLOAD command
(Issue #187 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/issues/187>_)Issue #180 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/180>_)Issue #181 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/issues/181>_)Issue #186 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/186>_)Issue #178 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/178>_)Issue #165 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/165>_)SQLAlchemy >= 1.3.0
(Issue #161 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/161>_)Issue #159 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/159>_)MAXFILESIZE argument to UNLOAD.
(Issue #123 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/issues/123>_)CREATE LIBRARY_ command.
(Issue #124 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/issues/124>_)ALTER TABLE APPEND_ command.
(Issue #162 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/162>_)CSV format to UnloadFromSelect.
(Issue #169 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/issues/169>_)Issue #176 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/issues/176>_).. _CREATE LIBRARY: https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_LIBRARY.html .. _ALTER TABLE APPEND: https://docs.aws.amazon.com/redshift/latest/dg/r_ALTER_TABLE_APPEND.html
REGION argument to COPY and UNLOAD commands.
(Issue #90 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/issues/90>_)Issue #140 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/140>_)header option to UnloadFromSelect command
(Issue #156 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/156>_)Issue #151 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/150>_)Issue #153 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/153>_)Issue #147 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/147>_)Issue #138 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/issues/138>_)search_path with external schemas (Issue #120 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/120>_)Issue #133 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/133>_)transitional ACM cert bundle <https://docs.aws.amazon.com/redshift/latest/mgmt/connecting-transitioning-to-acm-certs.html>_
(Issue #130 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/130>_)Issue #88 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/88>_)Issue #96 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/issues/96>_)Issue #97 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/97>_)Issue #101 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/issues/101>_)Issue #110 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/issues/110>_)Issue #114 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/114>_)Issue #94 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/issues/94> _)Issue #70 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/70>_)__table_args__ = {'redshift_sortkey': ('foo, bar')}. Previously, this would sort
on the columns named foo and bar. Now, it sorts on the column named foo, bar.
(Issue #74 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/74>_)sqlalchemy_redshift to match the naming
convention for other dialects; the redshift_sqlalchemy package now emits
a DeprecationWarning and references sqlalchemy_redshift.
The redshift_sqlalchemy compatibility package will be removed
in a future release.
(Issue #58 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/58>_)CREATE TABLE statements, particularly for columns with an IDENTITY
constraint.
(Issue #60 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/60>_)NoSuchTableError
in cases where its schema is not on the current search_path
(Issue #64 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/64>_)Issue #61 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/61>_)Fix breakages to CopyCommand introduced in 0.3.0:
Thanks solackerman <https://github.com/solackerman>.
(Issue #53 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/53>)
format is omitted, no FORMAT AS ... is appended to the query. This
makes the default the same as a normal redshift query.Fix view support to be more in line with SQLAlchemy standards.
get_view_definition output no longer includes a trailing semicolon and
views no longer raise an exception when reflected as Table objects.
(Issue #46 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/46>_)
Rename RedShiftDDLCompiler to RedshiftDDLCompiler.
(Issue #43 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/43>_)
Update commands
(Issue #52 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/52>_)
bouk <https://github.com/bouk>.
(Issue #15 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/15>)Issue #20 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/20>_)Issue #21 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/21>_)Issue #13 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/13>_)Issue #27 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/27>_)Issue #34 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/34>_)DELETE statements that refer other tables in
the WHERE clause.
Thanks haleemur <https://github.com/haleemur>.
(Issue #35 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/issues/35>)NoSuchTableError when trying to reflect a table that doesn't exist.
(Issue #38 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/issues/38>_)bouk <https://github.com/bouk>.
(Issue #7 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/7>)