Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Import data from a MySQL database table into a Pandas DataFrame using the pymysql package.
mport pandas as pd
import pymysql
from sqlalchemy import create_engine
engine = create_engine("mysql+pymysql://USER:PASSWORD@HOST:PORT/DBNAME")
df = pd.read_sql_query("SELECT * FROM table", engine)
df.head()
@azizatitallah

This comment has been minimized.

Copy link

@azizatitallah azizatitallah commented Feb 27, 2018

I was looking for this, Thanks 🍏

@muthu0101

This comment has been minimized.

Copy link

@muthu0101 muthu0101 commented Sep 11, 2018

Thank You

@sourcetop

This comment has been minimized.

Copy link

@sourcetop sourcetop commented Sep 15, 2018

Great snippet.
Thanks!

@rahman9909

This comment has been minimized.

Copy link

@rahman9909 rahman9909 commented Sep 15, 2018

Great, Thanks

@jordaniza

This comment has been minimized.

Copy link

@jordaniza jordaniza commented Mar 26, 2019

Had a few difficulties getting this to run - removed the square brackets around [:] did the job, hope that helps anyone struggling.

Really helpful though, thanks!

@userddssilva

This comment has been minimized.

Copy link

@userddssilva userddssilva commented Jan 31, 2020

thanks man

@dariusmortazavi

This comment has been minimized.

Copy link

@dariusmortazavi dariusmortazavi commented Mar 28, 2020

I also removed the square brackets around the port and that worked for me too @jordaniza! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment