66
77import pkg_resources
88import sqlalchemy as sa
9+ from sqlalchemy .sql import text
910from packaging .version import Version
1011from sqlalchemy import inspect
1112from sqlalchemy .dialects .postgresql import DOUBLE_PRECISION
@@ -753,7 +754,7 @@ def get_check_constraints(self, connection, table_name, schema=None, **kw):
753754 )
754755 table_oid = 'NULL' if not table_oid else table_oid
755756
756- result = connection .execute (sa . text ("""
757+ result = connection .execute (text ("""
757758 SELECT
758759 cons.conname as name,
759760 pg_get_constraintdef(cons.oid) as src
@@ -796,7 +797,7 @@ def get_table_oid(self, connection, table_name, schema=None, **kw):
796797 schema_field = '"{schema}".' .format (schema = schema ) if schema else ""
797798
798799 result = connection .execute (
799- sa . text (
800+ text (
800801 """
801802 select '{schema_field}"{table_name}"'::regclass::oid;
802803 """ .format (
@@ -894,7 +895,7 @@ def get_view_definition(self, connection, view_name, schema=None, **kw):
894895 :meth:`~sqlalchemy.engine.interfaces.Dialect.get_view_definition`.
895896 """
896897 view = self ._get_redshift_relation (connection , view_name , schema , ** kw )
897- return sa . text (view .view_definition )
898+ return text (view .view_definition )
898899
899900 def get_indexes (self , connection , table_name , schema , ** kw ):
900901 """
@@ -1060,7 +1061,7 @@ def _get_all_relation_info(self, connection, **kw):
10601061 ) if table_name else ""
10611062 )
10621063
1063- result = connection .execute (sa . text ("""
1064+ result = connection .execute (text ("""
10641065 SELECT
10651066 c.relkind,
10661067 n.oid as "schema_oid",
@@ -1122,7 +1123,7 @@ def _get_schema_column_info(self, connection, **kw):
11221123 )
11231124
11241125 all_columns = defaultdict (list )
1125- result = connection .execute (sa . text (REFLECTION_SQL .format (
1126+ result = connection .execute (text (REFLECTION_SQL .format (
11261127 schema_clause = schema_clause ,
11271128 table_clause = table_clause
11281129 )))
@@ -1147,7 +1148,7 @@ def _get_all_constraint_info(self, connection, **kw):
11471148 ) if table_name else ""
11481149 )
11491150
1150- result = connection .execute (sa . text ("""
1151+ result = connection .execute (text ("""
11511152 SELECT
11521153 n.nspname as "schema",
11531154 c.relname as "table_name",
@@ -1434,6 +1435,10 @@ def create_connect_args(self, *args, **kwargs):
14341435 default_args .update (cparams )
14351436 return cargs , default_args
14361437
1438+ def _set_backslash_escapes (self , connection ):
1439+ # Redshift doesn’t implement SHOW standard_conforming_strings
1440+ self ._backslash_escapes = "off"
1441+
14371442
14381443def gen_columns_from_children (root ):
14391444 """
0 commit comments