Insert data into a snowflake table from sqlachemy

182 views Asked by At

So I am trying to insert data into a snowflake transient table (from a parquet file), but my syntax doesn't allow me to go past our SAST test in the pipeline.

Do you see anything wrong with the following code snippet (especially the insert into step since it is causing the error):

with snowflake_engine.begin() as tx:
(SOME WORKING CODE)...
        if table == "lending_adjudications":
            tx.execute(
                f"put file://{pq_filepath_2} @{destination_schema}.{stage_guid_part_2}"
            ).fetchall()

            stmts = [
                f"create or replace transient table {destination_schema}.{table} as "  # nosec
                f"select $1 as fields from @{destination_schema}.{stage_guid}",  # nosec
                f"insert into {destination_schema}.{table} "
                f"select $1 as fields from @{destination_schema}.{stage_guid_part_2}",
            ]

            [tx.execute(stmt).fetchall() for stmt in stmts]

        else:
            tx.execute(
                f"create or replace transient table {destination_schema}.{table} as "  # nosec
                f"select $1 as fields from @{destination_schema}.{stage_guid}"  # nosec
            ).fetchall()
...

Thank you so much for your help, any insight is highly appreciated.

0

There are 0 answers