Last active
December 26, 2023 19:48
-
-
Save stefanthoss/364b2a99521d5bb76d51 to your computer and use it in GitHub Desktop.
Import data from a MySQL database table into a Pandas DataFrame using the pymysql package.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Thank You
Great snippet.
Thanks!
Great, Thanks
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!
thanks man
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
I was looking for this, Thanks 🍏