Read a MySQL Table and Write Its Contents

In this example, we use the REST Post Snap to read a table in MySQL and write the contents to a file. It is designed to run against the MySQL sample database sakila, but can be easily adapted to work against any database.

This example consists of two pipelines:

  • REST_MySql_to_file_1_of_2
  • REST_MySql_to_file_2_of_2
  1. Download and upload both pipelines

    Download the Pipelines, decompress them, and upload both into a single project in SnapLogic.

  2. Configure MySQL and REST Post

    Change the MySQL user account in Pipeline 2 and create a task for Pipeline 2. Then paste the task name into the JSON document Snaplex attribute.

  3. Run the Pipeline

    Run Pipeline 1. It will create a file in the local project containing the MySQL table data.

This example illustrates:

  • How to use REST Post to invoke a remote service.
  • How to convert a pipeline parameter to a document parameter.
  • How to populate a column in a database with the current datetime.
  • How to convert a JSON document to a flat CSV file.