[python]SQLAlchemy create mysql table

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!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s