Skip to content

Commit 2962858

Browse files
committed
Cleaning up merge
Signed-off-by: Jason Myers <[email protected]>
2 parents 294bc65 + 15642f9 commit 2962858

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

redshift_sqlalchemy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '0.3'
1+
__version__ = '0.3.1'
22

33
from sqlalchemy.dialects import registry
44

redshift_sqlalchemy/dialect.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from sqlalchemy.types import VARCHAR, NullType
55
from sqlalchemy.ext.compiler import compiles
66
from sqlalchemy.sql.expression import Executable, ClauseElement
7+
from sqlalchemy.sql.expression import BindParameter
78

89

910
class RedshiftDialect(PGDialect_psycopg2):
@@ -84,8 +85,19 @@ def visit_unload_from_select(element, compiler, **kw):
8485
import pdb; pdb.set_trace()
8586
query_str = str(query).replace("'", "\'")
8687
return "unload ('%(query)s') to '%(bucket)s' credentials 'aws_access_key_id=%(access_key)s;aws_secret_access_key=%(secret_key)s' delimiter ',' addquotes" % {
87-
'query': query_str,
88+
'query': compiler.process(element.select, unload_select=True, literal_binds=True),
8889
'bucket': element.bucket,
8990
'access_key': element.access_key,
9091
'secret_key': element.secret_key,
9192
}
93+
94+
@compiles(BindParameter)
95+
def visit_bindparam(bindparam, compiler, **kw):
96+
#print bindparam
97+
res = compiler.visit_bindparam(bindparam, **kw)
98+
if 'unload_select' in kw:
99+
#process param and return
100+
res = res.replace("'", "\\'")
101+
return res
102+
else:
103+
return res

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='redshift-sqlalchemy',
5-
version='0.3',
5+
version='0.3.1',
66
description='Amazon Redshift Dialect for sqlalchemy',
77
long_description=open("README.rst").read(),
88
author='Matt George',

0 commit comments

Comments
 (0)