Schedule SQL cron tasks
Use the boilerplate code below to create a
task.pyfile in your Lair’s root directory. See File system for more details on how to manipulate files in your workspace file system.
# These credentials can be found via your database credentials page
# For additional help with these values, please visit the docs of where your database is hosted.
mydb = mysql.connector.connect(
# SQL statement to execute
sql = "SELECT * FROM earnings;"
mycursor = mydb.cursor()
myresult = mycursor.fetchall()
Open your Lair’s
.triggersfile and add a new
crontrigger. Create a name for your trigger, input the following run command, and set an interval or custom cron syntax for your task. See Triggers for more details.
Example Cron Trigger Setup
Press “Test” to execute the run command and start your task’s process execution. A process tab should open in your Terminal view.
Press Test in your Triggers view to test your cron Trigger. When ready, deploy it to production!
pip install -r requirements.txt
pip freeze > requirements.txt
Your task will not be scheduled within your Lair’s development environment. Once you have finished testing, Go to the Deploy Panel to deploy a production instance of your task.