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.
import 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
Copy link

I was looking for this, Thanks 🍏

@muthu0101
Copy link

Thank You

@sourcetop
Copy link

Great snippet.
Thanks!

@rahman9909
Copy link

Great, Thanks

@jordaniza
Copy link

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
Copy link

thanks man

@dariusmortazavi
Copy link

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