DataCamp Workspace also supports a connection to a MySQL database. Using environment variables, you can connect your own database to your workspace. Make sure you understand how you can set up and connect environment variables securely to your workspace before setting up this specific integration. You can read this article for more info.
You can set up the MySQL integration as follows. The names you choose for your environment variables should be consistent with the ones you use in your workspace.
You can now use these environment variables to define a connection to a MySQL database. Check out this code snippet as an example:
from sqlalchemy import create_engine
import pandas as pd
# Connect to the database
connection = pymysql.connect(
# Execute a query and put result in pandas dataframe
sql_df = pd.read_sql(
"SELECT * FROM employees",
Sample database: employees
We also provide you with a sample database about employees (source). If you want to connect to this database to get more familiar with the MySQL integration, there are only two things you will need to do.
Next, connect the following set of credentials to your workspace. These will give you access to the sample database.
MYSQL_HOST = workspacemysqldemodb.datacamp.com
MYSQL_NAME = employees
MYSQL_PASSWORD = workspace
MYSQL_USERNAME = workspace