Skip to content

Instantly share code, notes, and snippets.

@Razzo78
Last active January 26, 2018 09:30
Show Gist options
  • Save Razzo78/8edf79e9f21440ce47c963bb8a9780a2 to your computer and use it in GitHub Desktop.
Save Razzo78/8edf79e9f21440ce47c963bb8a9780a2 to your computer and use it in GitHub Desktop.
Python, Sqlite - Import data from CSV with DbImport class
import pandas as pd
df_data = pd.read_csv("fileName.csv", sep='\t')
# DbImport: https://gist.github.com/Razzo78/3580cf9ed1f3c9a34484ab887b6dbf5d
db = DbImport("myDb.sqlite")
data_ins = {"filed_id": -1,
"filed_name": ""
}
for index, row in df_data.iterrows():
# Create an object tot import data in to the database
data_ins['filed_id'] = int(row['CSV ID'])
data_ins['filed_name'] = string(row['CSV NAME'])
db.insert_new_table_1_name(data_ins)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment