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()