Answers for "how to connect mysql database in jupyter notebook"

SQL
0

connect to mysql database jupyter

# In the python cmd, install packages:
pip3 install pymysql
pip3 install ipython-sql
pip3 install mysqlclient

# in the jupyter notebook:
import pymysql
import pandas as pd

conn=pymysql.connect(host='localhost',port=int(3306),user='root',passwd='YOUR_PASSWORD',db='YOUR_DATABASENAME')

df=pd.read_sql_query("SELECT * FROM 'YOUR_TABLENAME' ",conn)

print(df)
Posted by: Guest on March-30-2021
0

how to connect mysql database in jupyter notebook

# %%
%load_ext sql

# %%
%sql mysql+mysqldb://<user>:<password>@localhost/<dataBase>

# %%
%%sql

SELECT *
FROM <table>;
Posted by: Guest on May-05-2020

Code answers related to "SQL"

Browse Popular Code Answers by Language