This tutorial uses WayScript - a rapid programming platform for developers. It's currently in beta, and we'd love feedback from the DEV community.
Whatever your reason, sometimes we need to share data between different sources. Whether this be to allow certain members of your team access, enable additional data processing, data visualization, or anything else, WayScript can make this process easy. In this tutorial, let's take a look at how we can extract data from a SQL based database and write it to a google sheet.
To start off, we'll need to access your database. To do this on WayScript, we'll first need to drag an SQL module into our workflow:
Once in our workflow, we'll need to select "Add an Account" to the left. It will be at the bottom of your already added databases, should you of already connected one.
Once we select this, we'll be prompted for the credentials of our database. We can usually find these on the settings of the database.
Once we input this information, we'll be able to do reads and writes to our database using the text editor. Hovering over the pre-generated code, we get an option to edit:
Here we want to write a statement to query the desired information from our database. We'll use some some simple:
The desired data needs to be imported, and you can rename the column if you'd like. This creates a variable within WayScript that we can write to a google sheet. These creates variables will have a list type, so we'll need to loop through these to write them to google sheets.
As mentioned, the output variables from the database will have a list type. So we'll need to loop through each value in this list to write them to a google sheet. To do this, we'll pull in the loop logic module.
This works just as it would in a programming language, we'll select the iterable type that we want to iterate over. This will give us an item of that list to preform an action with. In this example, we have the "scores" list and iterating gives us a "score_item."
We'll drag in the google sheets module inside our loop. From here, we'll just need to configure a few pieces to be sure that our list is written.
And just like that, we're writing database data to your google sheets!
If there's any questions feel free to message us here on DEV or on discord. We're happy to help! If you want to see this full script template, you can find it here.