Skip to content

Instantly share code, notes, and snippets.

@joshlk
Created August 4, 2016 19:35
Show Gist options
  • Save joshlk/a87616534b52a1321d4e124ae890f09d to your computer and use it in GitHub Desktop.
Save joshlk/a87616534b52a1321d4e124ae890f09d to your computer and use it in GitHub Desktop.
Pandas to Sqlite
import pandas as pd
from sqlalchemy import create_engine
df = pd.read_csv('<INPUT_FILE_PATH>.csv', encoding='utf') # Needs to be unicode for sqlite
disk_engine = create_engine('sqlite:///<DB_PATH>.sqlite')
df.to_sql('<TABLE_NAME>', disk_engine, if_exists='append')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment