First, you need to obtain the credential required to connect to the database which include an IP address of the server, a username and a password. Once obtained, it is preferable to put these infos in your .bash_profile located in your /home folder. Note : The following instruction only work Unix like system using bash as shell, Windows users may use the instruction from this site in order to achieve the same result.



Adding login infos into the .bash_profile in Python

export MdB_HOST='xxx.xxx.x.xx'
export MdB_USER='XXX_xxx'
export MdB_PASSWD='xxxxxxxx'
export MdB_PORT='3306'
export MdB_DB='3MdBs'

The export makes the login infos available to sub-processes via variables as declared in the .bash_profile. As an example, the login variables can be called directly in Python as below. This way, you don't need to remember the infos and all example given on this site will work with a simple copy and paste.



Retrieving login infos via environment variables

import os
host = os.environ['MdB_HOST']
user = os.environ['MdB_USER']
passwd = os.environ['MdB_PASSWD']
port = os.environ['MdB_PORT']

The programming language preferred to interact with the database is Python. The following libraries must be installed in order to use all examples shown on this site :



These libraries does not come with Python already installed with Linux or Mac, the user can install them via the package manager pip or via Anaconda distribution software. We strongly suggested to use Python version 3 instead of 2.