On previous post, SQlite3 was created using SQLAlchemy, to change from SQLite to MySQL, you need to download pymysql
module then change the URI from sqlite:///objects.db
to mysql+pysql://[username]:[password]@[ip address of the mysql server]/[database name]
example if username is cyruslab and password is mypassword and ip address of mysql is 192.168.1.1 and database name is firewall_objects then the uri is mysql+pymysql://cyruslab:mypassword@192.168.1.1/firewall_objects
Before running the python script, need to create a database from mysql or mariadb using create database firewall_objects
where firewall_objects
is the database name. The rest of the code from the previous post is unchanged.
Kudos to the creator of SQLAlchemy!