SQLite Sample table with Date column

SQLite

Place part 1, part 2 and part 3 in the same sequence and execute

part 1
import sqlite3
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)")
my_conn.commit()
part 2 part 3
r_set=my_conn.executemany("INSERT INTO dt_table VALUES (?, ?,?)",data)
my_conn.commit()
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.

Here is a sample ipynb file used to create the database with sample data. Note that the data tuple changes every day.
View & Download sample ipynb file (.html format)

Sqlite Date Query insert update selectOrder By


plus2net.com



Post your comments , suggestion , error , requirements etc here




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer