Connecting Source data application ie mysql database to openfn!

I have few questions about Connecting Source data application to openfn!

1- How to connect the database directly as a source application?If connected to a database as a source app how to fetch data from the database which is already stored in it? how to set up a trigger for it?
2- for eg: I have form data in kobotoolbox platform, after connecting it to openFn how to fetch the form data which is already there in kobotoolbox? how to fetch data that is already stored in the source app(kobotoolbox form-data), then what we must set for the trigger?

any help! thanks in advance!!

Hi @jashwanth_gowda , welcome! Great questions.

  1. If your database application has some way of emitting webhook events (like a “trigger” in Postgres that could make a web request when a record got inserted) then you could configure it to send that data to OpenFn using your inbox url. If you’ve got some out-of-the-box MySql, Postgres, MongoDb or MSSQL database however, you’ll proabbly need to go and fetch data from it. Try creating a cron trigger that will fetch data every hour 0 * * * * and then a job using the postgres adaptor (for example) with an expression like:
    sql(state => 'select(*) from some_table;'). You can use the data you get from your postgres DB in your next job.
  2. For Kobo, I’d recommend sending data from Kobo to OpenFn using their webhooks service. Make a trigger that selects something standard from the body of the messages that start arriving in your inbox… here’s an overview of triggers.

Hope this is a helpful start! Keep the questions coming :slight_smile:

hi Taylor,
1- in database one, trigger a job when new data received is fine.
Now I am using MySQL database as the source, I have data already stored inside it, how to connect MySQL database to openfn and fetch the data from the database, and use that data,then how to set up the trigger and run the job?? any documentation or video guide for this??
2 - for kobo, your recommended way is what I have done but my doubt is I have already form data in the kobotoolbox platform before connecting it to openfn, after connecting it openfn, how to retrieve old data which is already there in kobotool box and set up the trigger and run the job??

hoping for a reply!!

Sure thing!

  1. It looks like sqlString(state => "select * from items;") will work for the mysql adaptor and you can do everything else exactly as I’ve written in my first response with the postgres example. Re: setting up a job… yes, many examples! Start here and then maybe check out some of the videos on Youtube. Like this one. Hard to get too specific without knowing what you’re trying to do with this Kobo data.
  2. Ahhhh. Interesting. I think that getSubmissions(...) is probably what you want. Used in conjunction with getForms(...) you could grab all the data from a Kobo instance and do something with it.

hey Taylor,
I will try and get back to you around kobo !!
Do you have any resources or links for connecting the MySQL database as a source application to the openfn platform?

1 Like