Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@erogol
Created November 12, 2014 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erogol/33f2dc67bf28c0a74325 to your computer and use it in GitHub Desktop.
Save erogol/33f2dc67bf28c0a74325 to your computer and use it in GitHub Desktop.
import pandas as pd
from sqlalchemy import *
engine = create_engine('mysql://username:pass@server_address', pool_recycle=60)
DF = pd.io.parsers.read_csv('csv/file/path.csv')
DF = DF.dropna()
DF.to_sql('table_name', con=engine, if_exists='replace', flavor='mysql') # replace truncates the existing table and creates a new one
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment