Tutorial: Update Airtable Rows with mySQL data and Python Processing
Tags: python, tutorial, beginners, mySQL
Published: 2020-05-07 13:27:47

---
title: "Tutorial: Update Airtable Rows with mySQL data and Python Processing"
canonical_url: https://wayscript.com/learn/update-airtable-rows-mysql-data-python-processing
---
{% youtube q3KNsvtIFqM %}

##Introduction
Connecting mySQL, python, and airtable has never been this easy to do. In this example using [WayScript](https://wayscript.com/), let's walk through ho we can pull information from a mySQL database, process it using python programming, and then input that data into our Airtable database.

##Prerequisites
No prerequisites but some content you might find helpful:
[Working with databases](https://docs.wayscript.com/library/modules/sql)
[Working with CRON](https://docs.wayscript.com/library/triggers/time-trigger)
[Working with Airtable](https://docs.wayscript.com/library/modules/airtable)
[Working with Python](https://docs.wayscript.com/library/modules/python)

##Activating a Script Routinely
To activate any script on WayScript at set intervals, on certain days, or at certain time, we offer the use of the time trigger:

![time trigger](https://cdn.wayscript.com/blog_img/74/1.png)

We're able to do anything fancy that you might want to using full CRON syntax to denote when we want to activate our script.

For the purposes of simplicity, let's make our's run everyday.

![Schedule](https://cdn.wayscript.com/blog_img/74/2.png)

Once we have this, anything contained in this tree will be executed, everyday, at 7AM.

##Connecting our Database
To connect our database, we'll need to drag it into our workflow below our time trigger.

![database connection](https://cdn.wayscript.com/blog_img/74/3.png)

Once here, we'll need to provide some information for WayScript to be able to read/write your database. If you need help with setting up your database, our documentation has a full video and text walkthrough. As with anything else, if you get stuck feel free to reach out to us on our discord as well.


##Using a Date time module
If we want to pass today's date to airtable each time we execute our script, we can use the date time module.

![date time](https://cdn.wayscript.com/blog_img/86/1.png)

This gives us access to a variable in our variables panel that we can pass to airtable later on.

##Executing your Database Action
Now that we have the database in the workflow, we're able to write SQL statements and execute those against our tables just like how we would locally. Click edit code to the left:

![edit code](https://cdn.wayscript.com/blog_img/74/4.png)

This will give us access to the text editor, in which we can write our own custom code. Let's just put something simple in:

```python
SELECT SUM(score) from survey;
```
This will give us back the query value as a variable we can use throughout the rest of our script.

##Processing with Python
To process the data that we pull from airtable with python, we can pull in a python module below the SQL module.

![python](https://cdn.wayscript.com/blog_img/86/2.png)

From here we can edit the code and write something like this:
```python
sum_a = variables['Column_0']
print(sum_a)
​
sum_b = int(sum_a)*2
print(sum_b)
​
variables[ 'sum_b' ] = sum_b
```
We're just doing a bare bones processing operation here of multiplying our value by two, but this step could be much more depending on your requirements.

##Passing to Airtable
Once the variable is passed back from the python module, we can input it into airtable. Drag an airtable module below this python step and then configure the settings:

![airtable](https://cdn.wayscript.com/blog_img/86/3.png)

We're writing the values that we created throughout the steps to our airtable, using the create a new record mode.

##Questions, Need Help?
If you have any questions, comment below or feel free to message us on [Discord](https://discord.gg/nchf9E9). We're happy to help! If you want to see this full script template, you can find it [here](https://wayscript.com/user/derricks/Rm1K-7HQ).