Overwrite MySQL tables with AWS Glue

后端 未结 3 967
时光取名叫无心
时光取名叫无心 2021-01-12 17:38

I have a lambda process which occasionally polls an API for recent data. This data has unique keys, and I\'d like to use Glue to update the table in MySQL. Is there an optio

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-12 18:41

    I found a simpler way working with JDBC connections in Glue. The way the Glue team recommends to truncate a table is via following sample code when you're writing data to your Redshift cluster:

    datasink5 = glueContext.write_dynamic_frame.from_jdbc_conf(frame = resolvechoice4, catalog_connection = "", connection_options = {"dbtable": "", "database": "testdb", "preactions":"TRUNCATE TABLE "}, redshift_tmp_dir = args["TempDir"], transformation_ctx = "datasink5")
    

    where

    connection-name your Glue connection name to your Redshift Cluster
    target-table    the table you're loading the data in 
    testdb          name of the database 
    table-name      name of the table to truncate (ideally the table you're loading into)
    

提交回复
热议问题