forked from sqlalchemy-redshift/sqlalchemy-redshift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matt George
committed
Apr 15, 2013
0 parents
commit 79373a1
Showing
6 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*pyc | ||
*swp | ||
.DS_Store | ||
dist | ||
*.egg-info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright (c) 2013 Matt George | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
redshift_sqlalchemy | ||
================== | ||
|
||
Amazon Redshift dialect for sqlalchemy. | ||
|
||
Requirements | ||
------------- | ||
* pysocpg2 >= 2.5 | ||
* SQLAlchemy 0.8 | ||
|
||
|
||
Usage | ||
----- | ||
DSN format is simpilar to that of regular postgres: | ||
|
||
from sqlalchemy import create_engine | ||
|
||
engine = create_engine("redshift+psycopg2://username@localhost:5439/database" | ||
|
||
Notes | ||
----- | ||
|
||
Currently, contraints and indexes return nothing when intropecting tables. This comes from the redshift implementation of the postgresql api == 8.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
__version__ = '0.1' | ||
|
||
from sqlalchemy.dialects import registry | ||
|
||
registry.register("redshift", "redshift_sqlalchemy.dialect", "RedshiftDialect") | ||
registry.register("redshift+psycopg2", "redshift_sqlalchemy.dialect", "RedshiftDialect") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from sqlalchemy.dialects.postgresql.psycopg2 import PGDialect_psycopg2 | ||
from sqlalchemy.engine import reflection | ||
|
||
class RedshiftDialect(PGDialect_psycopg2): | ||
@reflection.cache | ||
def get_pk_constraint(self, connection, table_name, schema=None, **kw): | ||
""" | ||
Constraints in redshift are informational only. This allows reflection to work | ||
""" | ||
return {'constrained_columns': [], 'name': ''} | ||
|
||
@reflection.cache | ||
def get_indexes(self, connection, table_name, schema, **kw): | ||
""" | ||
Redshift does not use traditional indexes. | ||
""" | ||
return [] | ||
|
||
def set_isolation_level(self, connection, level): | ||
from psycopg2 import extensions | ||
connection.set_isolation_level(extensions.ISOLATION_LEVEL_AUTOCOMMIT) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from setuptools import setup | ||
|
||
setup( | ||
name='redshift-sqlalchemy', | ||
version='0.1', | ||
description='Amazon Redshift Dialect for sqlalchemy', | ||
long_description=open("README.md").read(), | ||
author='Matt George', | ||
author_email='[email protected]', | ||
license="MIT", | ||
url='https://github.com/binarydud/redshift_sqlalchemy', | ||
packages=['redshift_sqlalchemy'], | ||
install_requires=['psycopg2 >= 2.4.1'], | ||
include_package_data=True, | ||
zip_safe=False, | ||
classifiers=[ | ||
"Development Status :: 3 - Alpha", | ||
"Environment :: Console", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python", | ||
], | ||
entry_points={ | ||
'sqlalchemy.dialects': [ | ||
'redshift = redshift_sqlalchemy.dialect:RedshiftDialect', | ||
'redshift.psycopg2 = redshift_sqlalchemy.dialect:RedshiftDialect', | ||
] | ||
} | ||
) | ||
|