Friends, is there any way to connect Python 3 with MariaDB? Also, could you indicate any material in English or Portuguese?
Thank you in advance!
Friends, is there any way to connect Python 3 with MariaDB? Also, could you indicate any material in English or Portuguese?
Thank you in advance!
To connect to MariaDB using the MySQL Python module in your program, you have to import it first, just like any other module. For clarity and ease of use, import the connector class only under the import mysql.connector as mariadb name. I will use the class under the name mariadb in the following examples. Then, establish a database connection with code like mariadb_connection = mariadb.connect (user = 'python_user', password = 'some_pass', database = 'employees') where you assign actual values for user, password and database. Finally, to begin interacting with the database and running queries, you need to instantiate the cursor object with the cursor = mariadb_connection.cursor () tag. So far, your initial code should look something like this:
Import mysql.connector as mariadb
Mariadb_connection = mariadb.connect (user = 'python_user', password = 'some_pass', database = 'employees') Cursor = mariadb_connection.cursor ()
Here you have the complete, easy-to-understand material: link
As MariaDB is the same MySQL core, you can use the same MySQL module to access the DB.