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 & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.