Konversi Excel ke SQLite dengan Google Collab

Masih seperti sebelumnya, ini adalah cara paling praktis untuk melakukan konversi Excel ke SQLite menggunakan google Collabs

Mount Drive

1
2
3
# mount drive
from google.colab import drive
drive.mount('/content/drive')

Buka Excel dan Konversi ke sqlite

#import library
import pandas as pd
import sqlite3
 
#open file from excel to dataframe
file = "/content/drive/MyDrive/Colab Notebooks/STUDI KASUS - SIMULASI RETAIL.xlsx"
df = pd.read_excel(file, sheet_name=0) 
 
#create database and connect it
database = "/content/drive/MyDrive/Colab Notebooks/retail_fromxlsx.sqlite3"
conn = sqlite3.connect(database)
 
#save data to sqlite
df.to_sql(name='retail', con=conn)
conn.close()