import sqlite3
my_path='F:\\testing\\sqlite\\my_db.db' #Change the path of your database
try:
my_conn = sqlite3.connect(my_path) #
except sqlite3.Error as my_error:
print("error: ",my_error)
else:
print("Connected to database successfully")
r_set=my_conn.execute("CREATE TABLE IF NOT EXISTS dt_table ( \
record_id varchar(4) NOT NULL, \
date text NOT NULL, \
`month-year` varchar(10) NOT NULL)")
my_conn.commit()
part 2 ( adding Data to Table )
Note that Part 2 changes every day ( dynamic ) based on the current date. We are using here previous 15 days and next 15 days as data for our table. This is required to run the queries based on today’s date.
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.