Skip to content

Instantly share code, notes, and snippets.

@tamiroze
Last active February 16, 2021 03:12
Show Gist options
  • Save tamiroze/a90a182da3ffa2f47c6b3b01320d79e6 to your computer and use it in GitHub Desktop.
Save tamiroze/a90a182da3ffa2f47c6b3b01320d79e6 to your computer and use it in GitHub Desktop.
Get Redshift tables
def run_data_migration(self, schema_name, table_name):
self.logger.info("querying redshift metadata")
pg_conn = pg.connect(cfg.REDSHIFT_DB_URL)
print "pg_conn:", pg_conn
pg_cursor = pg_conn.cursor()
if table_name != "none":
sql = """
select table_schema,table_name
from information_schema.tables
where table_schema= '{0}'
and table_type='BASE TABLE'
and table_name like '{1}%'
""".format(
schema_name, table_name
)
else:
sql = """
select table_schema,table_name
from information_schema.tables
where table_schema= '{0}'
and table_type='BASE TABLE' """.format(
schema_name
)
pg_cursor.execute(sql)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment