Skip to content

Instantly share code, notes, and snippets.

@zz2115
Created April 14, 2025 01:40
Show Gist options
  • Save zz2115/e4422fc52848cffea77bd001d9e47a51 to your computer and use it in GitHub Desktop.
Save zz2115/e4422fc52848cffea77bd001d9e47a51 to your computer and use it in GitHub Desktop.
sqlalchemy redshift_custom
from sqlalchemy.dialects import registry
from sqlalchemy.dialects.postgresql.psycopg2 import PGDialect_psycopg2
class RedshiftPostgresDialect(PGDialect_psycopg2):
def _set_backslash_escapes(self, connection):
self._backslash_escapes = "off"
registry.register("redshift_custom", __name__, "RedshiftPostgresDialect")
from sqlalchemy import create_engine
db = create_engine("redshift_custom://user:password@redshifthost:5439/dev")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment