Forums

Can I use SQLAlchemy to connect to MYSQL database when running a scheduled script?

I would like to run a scheduled script that updates my MYSQL database with data that I scrape from the web. In all the SQLalchemy tutorials I see the database connection is initialized using the flask app.

Because my script is not an actual app, is SQLalchemy the way to go for me or is there a different library I should be using to connect to the database?

it is possible. you can use sqlalchemy outside of flask webapps.

Yes, you can definitely use SQLAlchemy outside a web app. It's a really popular option for Flask, which is why there are so many tutorials showing the combination, but there's nothing to stop you from using it without. This help page has a note on an important setting you need to use if you're using it without Flask (there's a similar but differently-expressed setting if you are using Flask), and this tutorial looks like a good general introduction.