Last active
February 16, 2021 03:12
-
-
Save tamiroze/a90a182da3ffa2f47c6b3b01320d79e6 to your computer and use it in GitHub Desktop.
Get Redshift tables
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
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