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.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-02-04 11:00:00 +0000
Seen: 10 times
Last updated: Aug 20 '22
How do you log Python data into a database?
How can I load rows for child foreign keys in SQLite using C# ADO?
What does it mean when there is no database connection URL template for schemacrawler and sqlite3?
How to use the IN() clause in a subquery in Sqlite with a column name as data?
How can the SQL debug mode be activated in PostgreSQL version 15.2?
How to deal with an operational error when connecting Django to MySQL?
What is the method for choosing data FROM a stored procedure?