Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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)
Comment

how to connect mysql database in jupyter notebook

# %%
%load_ext sql

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

# %%
%%sql

SELECT *
FROM <table>;
Comment

PREVIOUS NEXT
Code Example
Python :: mario dance dance revolution 
Python :: check if coroutine python 
Python :: mirror 2d numpy array 
Python :: python dict order a dict by key 
Python :: django.db.utils.OperationalError: no such table: 
Python :: how to do swapping in python without sort function 
Python :: tkinter button background color mac 
Python :: how to move a column to last in pandas 
Python :: one hot encoding python pandas 
Python :: get a list of all files python 
Python :: ball bounce in pygame 
Python :: import python module from another directory 
Python :: ERROR: Failed building wheel for python-ldap 
Python :: python armstrong number 
Python :: random number pythn 
Python :: how to insert sound in python 
Python :: save strings with numpy savetext 
Python :: pyqt5 math 
Python :: convert string representation of a list to list 
Python :: system commands in python windwos 
Python :: python gtts 
Python :: check if user has manage messages discord.py 
Python :: char list to string python 
Python :: lda scikit learn 
Python :: pygame keys pressed 
Python :: change column value based on another column pandas 
Python :: openpyxl write in cell 
Python :: add y axis label matplotlib 
Python :: run file as administrator python 
Python :: find nan value in dataframe python 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =