MySQL to Socrata

This walkthrough goes through the steps of taking data from a MySQL database using RMySQL and loading it into an existing Socrata table using write.Socrata from RSocrata

View preview of workflow

This walkthrough assumes that you already have an instance of MySQL running on your machine. If that is not the case please stop and install that before continuing.

Step 1: Install Packages


Step 2: Connect to MySQL instance

Create constants so that R can access MySQL instance

con <- dbConnect(MySQL(),
    user = 'mysql',
    password = 'YourPass',
    host = 'RDS Host',

Step 3: Write to Data Frame

Use con to write to data.frame

table <- dbWriteTable(conn = con, name = 'Test')

Step 4: Identify Destination Dataset

Ensure that you have a Socrata dataset with proper fields and proper datatypes to write to. Capture the 4x4 ID for the dataset you want to publish to.

Step 5: Publish to Your Dataset

socrataEmail <- Sys.getenv("SOCRATA_EMAIL", "")
socrataPassword <- Sys.getenv("SOCRATA_PASSWORD", "XXXXXXX")
datasetToAddToUrl <- "" 

Step 6: Done!

Enjoy your new dataset!