How to run python scripts in MySQL container?

We might soon be moving to Tutor. We are still in the exploration phase.

We have tons of scripts that consult the MySQL database under Native. Most of these scripts were written in python and using pymysql.

There is no python in the mysql container under Tutor.

I am not a docker expert nor a Tutor expert yet, but how can I add python at build time to the MySQL container?

P.S. I also need to output the results to the host and not the container.

I can always try mounting a volume from my host on the container through the docker-compose.override.yml file.

Then run my scripts from the lms container, where python is available, instead of the mysql container. That seems to be a potential solution.

How do I add pymysql to the lms container now?
I guess I can add it to the requirements in private.txt

You could also create a small plugin that adds a docker container to tutor’s docker-compose. In that container, you can install pymsql, provide MySQL service address and then run your scripts.
We made a plugin that does something along the same lines. It starts a container with a Django app that stores some data in the MySQL database. You might find some inspiration from there:

2 Likes

This is my favourite, most sustainable solution. Have no fear Pierre, embrace the way of the plugins!

I am no longer a Tutor Padawan :wink: