1 | initial version |
First, import the necessary libraries:
import sqlite3
import pandas as pd
Next, open a connection to the SQLite database:
conn = sqlite3.connect('database.db')
Then, read the Excel file using pandas and store it in a pandas DataFrame:
df = pd.read_excel('file.xlsx', sheet_name='sheet_name')
Finally, write the pandas DataFrame to the SQLite database:
df.to_sql(name='table_name', con=conn)
Note that you will need to replace 'database.db', 'file.xlsx', 'sheetname', and 'tablename' with the appropriate values for your specific situation.