Last active
February 16, 2021 03:13
-
-
Save tamiroze/30cca624b8098c62b26b0b9a8ac30059 to your computer and use it in GitHub Desktop.
Generate redshift ddl
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 get_table_ddl(self, table_name, schema_name): | |
self.logger.info("querying redshift metadata") | |
pg_conn = pg.connect(cfg.REDSHIFT_DB_URL) | |
pg_cursor = pg_conn.cursor() | |
sql = """ | |
select ddl | |
from vw_admin_generate_table_ddl | |
where tablename='{0}' | |
and schemaname='{1}' """.format( | |
table_name, schema_name | |
) | |
pg_cursor.execute(sql) | |
ddl = pg_cursor.fetchall() | |
pg_cursor.close() | |
print "ddl:", ddl | |
return ddl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment