connect sql server jupyter notebook code example
Example 1: how to connect mysql database in jupyter notebook
%load_ext sql
%sql mysql+mysqldb:
%%sql
SELECT *
FROM <table>;
Example 2: connect to mysql database jupyter
pip3 install pymysql
pip3 install ipython-sql
pip3 install mysqlclient
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)