Connect to MySQL db from Jupyter notebook
问题 I am using Jupyter Notebooks to learn Python. I would like to connect to a MySQL db hosted locally hosted through MAMP. How would I approach this? 回答1: import os import pymysql import pandas as pd host = os.getenv('MYSQL_HOST') port = os.getenv('MYSQL_PORT') user = os.getenv('MYSQL_USER') password = os.getenv('MYSQL_PASSWORD') database = os.getenv('MYSQL_DATABASE') conn = pymysql.connect( host=host, port=int(3306), user="root", passwd=password, db="[YOUR_DB_NAME]", charset='utf8mb4') df = pd