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
Collecting 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.

Connection code

We encourage you to use our python script file (for python2 or python3) as a template for connecting to the MariaDB server. Briefly, the script executes the following functions:

  1. Identifies the appropriate runtime environment (compute grid, Mac, or Windows)
  2. Finds and loads the information from the .my.cnf file, the [client] or [mysql] section
  3. Builds the connection string with this data
  4. Establishes a connection to the MariaDB server and reports success or failure.

Feel free to add this to your python libraries, and see for more information on appropriate functions to use.