Skip to content

Instantly share code, notes, and snippets.

@Den1al
Forked from stefanthoss/mysql-pandas-import.py
Last active December 14, 2017 15:57
Show Gist options
  • Save Den1al/a50da28ace8378cd6f5d4447e02cb7dc to your computer and use it in GitHub Desktop.
Save Den1al/a50da28ace8378cd6f5d4447e02cb7dc to your computer and use it in GitHub Desktop.
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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment