Place part 1 and part 2 in the same sequence and execute.
New Database will be created if Path is correct and database name (file name ) is new.
part 1 ( Create dt_table table )
my_path='F:\\testing\\sqlite\\my_db.db' #Change the path of your database
my_conn = sqlite3.connect(my_path) #
except sqlite3.Error as my_error:
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)")
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.
Example : Collect last 5 days records. Collect records of present week , collect records starting from 1st of previous month.