Place part 1, part 2 and part 3 in the same sequence and execute
my_conn = sqlite3.connect('test2_db') # Change your database name here
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)")
r_set=my_conn.executemany("INSERT INTO dt_table VALUES (?, ?,?)",data)
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.
Example : Collect last 5 days records. Collect records of present week , collect records starting from 1st of previous month.