mirror of
https://git.sdf.org/tamservo/robottas.git
synced 2025-11-08 07:03:47 -05:00
Add next_event and next_race
This commit is contained in:
37
load_schedule.py
Normal file
37
load_schedule.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import csv
|
||||
import datetime
|
||||
import sqlite3
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
con = sqlite3.connect('schedule.db')
|
||||
cur = con.cursor()
|
||||
cur.execute("""drop table schedule""")
|
||||
|
||||
# Create the table
|
||||
cur.execute("""create table schedule( id integer primary key, """ +
|
||||
"""title, session_type, date_start INTEGER,""" +
|
||||
"""location, round );""")
|
||||
|
||||
con.commit()
|
||||
|
||||
# Open the csv file
|
||||
with open("2024_schedule.csv") as csvfile:
|
||||
schedule_reader = csv.reader(csvfile, )
|
||||
for row in schedule_reader:
|
||||
sql_line = "INSERT INTO schedule (title, session_type, " + \
|
||||
"date_start, location, round) VALUES(" + \
|
||||
f"?, ?, ?, ?, ?)"
|
||||
|
||||
# Convert date into seconds
|
||||
date_str = row[2]
|
||||
date_obj = datetime.datetime.fromisoformat(date_str)
|
||||
|
||||
cur.execute(sql_line,
|
||||
(row[0], row[1], date_obj.timestamp(), row[3], row[4])
|
||||
)
|
||||
con.commit()
|
||||
|
||||
cur.close()
|
||||
con.close()
|
||||
Reference in New Issue
Block a user