Пример #1
0
def create_tables(cur, conn):
    """
    This method runs create table queries listed in create_table_queries
    :param cur: Cursor to redshift
    :param conn: Connection to Redshift
    :return:
    """
    for table_name, query in create_table_queries.items():
        cur.execute(query)
        conn.commit()
        log.info(f"created table: {table_name}")
Пример #2
0
def create_tables(cur, conn):
    """
        Creates all the tables in using the queries form 'create_table_queries'
        
        Args:
            cur:   sql cursor
            conn:  psycopg2 connection object to the database
    """

    print("Creating all tables")
    for table, query in create_table_queries.items():
        cur.execute(query)
        conn.commit()
        print(f"- Table '{table}' created")
Пример #3
0
def create_tables(cur, conn):
    """
    create DWH fact and dimension tables
    """

    for table, query in create_table_queries.items():
        try:
            cur.execute(query)
            conn.commit()
            print(f"Create table command succeeded for table '{table}'.")
        except psycopg2.Error as e:
            print(f"Create table command failed for table '{table}'.")
            print(e)
            conn.rollback()
            continue
def create_tables(cur, conn):
    #initialize tables with constraints
    for table,query in create_table_queries.items():
        print('Creating table: ', table)
        cur.execute(query)
        conn.commit()
Пример #5
0
def create_tables(cur, conn):
    for name, query in create_table_queries.items():
        print(name)
        print(query)
        cur.execute(query)
        conn.commit()