Read/Write data from/to SQLITE using Python Pandas

twitter logo github logo ・1 min read

data-engineering (2 Part Series)

1) Read/Write data from/to SQLITE using Python Pandas 2) Read Excel sheet using Pandas

PUSH EXCEL FILE TO SQLITE FILE

import pandas as pd
import sqlite3

EXCEL_FILE_NAME = 'source.xlsx'
DB_NAME = 'stage.db'

df= pd.read_excel(open(EXCEL_FILE_NAME , 'rb'),skiprows=3,index=False)

conn = sqlite3.connect(DB_NAME)
df.to_sql('source', conn)

READ FROM SQLITE



import pandas as pd
import sqlite3

DB_NAME = 'stage.db'

conn = sqlite3.connect(DB_NAME)
sql_string = 'select * from source_tbl where id>10'
df = pd.read_sql(sql_string, conn)
print(df)
twitter logo DISCUSS
Classic DEV Post from Jul 13

Building A Career In Tech As A Newbie

muTheTechie profile image
Loving #opensource #AWS #python
profile pic

Don't be a stranger

Create your DEV Profile