In this video, we'll show you how to level up your data storage skills with Python. We'll use SQLite3 to store data in a single file, making it easy to access and manage.
Data storage is important for any digital project, and it's a skill that can be developed with a little bit of effort. In this video, we'll show you how to use Python and SQLite3 to store data in a single file, making it easy to access and manage. If you're looking to level up your data storage skills, be sure to check out this video!
Full code used in the video is:
import pandas as pd
import sqlite3
# Step 1: Read the data to a dataframe
path = r"yourfilepath/here/.xlsx"
df = pd.read_excel(path)
# # WRITING DATA TO SQLITE3
step 2: create or connect to a database
conn = sqlite3.connect('test.db')
step 3: read the data to the database
df.to_sql("Average_grades", conn, if_exists='replace', index=False)
#conn.commit()
conn.close()
#Step 4: Read the databack from the database to python
conn = sqlite3.connect('test.db')
df_fromdb = pd.read_sql_query('SELECT * FROM Average_grades', conn)
conn.close()
print(df_fromdb)