MariaDB allows you to connect directly to the database server using the native libraries that are part of the database server installation. Although Python does not have this capability natively, the two libraries pymysql and sqlalchemy add this functionality and make this almost effortless.
Python & libraries
We encourage you to use an Anaconda installation of Python, as most libraries needed for connecting to the database and fetching/saving data are there. If you are doing this on your local desktop/laptop, one additional library, pymysql, needs to be installed manually. From your terminal / shell / command line, issue
[12:43:44, jharvard@jharvard-mbp: ~]$ pip install pymysql
Using cached PyMySQL-0.7.11-py2.py3-none-any.whl
Installing collected packages: pymysql
Successfully installed pymysql-0.7.11
We encourage you to use this configuration file for all connections to the MariaDB server. This file contains the hostname of hte server, connection port, login credentials, and the location of the certificate file. You should have received this file from the RCS staff when you obtained your account and saved it at the appropriate location in your home folder. Guard this file as you would your credit card number! Please see our Configuration Files page for more information.
We encourage you to use our python script file (for python2 or python3) as a template for connecting to the MariaDB server. Please contact email@example.com for the sample script. Briefly, the script executes the following functions:
- Identifies the appropriate runtime environment (compute grid, Mac, or Windows)
- Finds and loads the information from the .my.cnf file, the [client] or [mysql] section
- Builds the connection string with this data
- Establishes a connection to the MariaDB server and reports success or failure.
Feel free to add this to your python libraries, and see https://www.sqlalchemy.org/ for more information on appropriate functions to use.