Photo by Tobias Fischer on Unsplash

How to connect Jupyter Notebook with a database using MySQL Connector

pip3 install mysql-connector
import os
import mysql.connector
username = os.environ.get('')
password = os.environ.get('')
host = os.environ.get('')
cnx = mysql.connector.connect(host = host,
port = #optional,
user = username,
passwd = password,
database = #database
)
auth_plugin='mysql_clear_password'
df = pd.read_sql_query('Select * FROM Table', cnx)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store