Compare commits

..
2 Commits
Author SHA1 Message Date
wylie 412f13692a Connect to new events database 2026-10-14 20:55:23 +11:00
wylie 1477d9ac7f Add database helper functions 2026-10-14 20:55:02 +11:00
2 changed files with 26 additions and 10 deletions
+6 -1
View File
@@ -1,2 +1,7 @@
import sqlite3
from .helpers import create_db
def main() -> None:
print("Hello from cs50-final-project!")
db = sqlite3.connect("events")
+20 -9
View File
@@ -1,9 +1,20 @@
def create_db(db):
# Create table storing calendar events
db.execute("""
CREATE TABLE IF NOT EXISTS events (
name TEXT NOT NULL,
description TEXT NOT NULL,
time DATETIME NOT NULL
length INT NOT NULL,);
""")
import sqlite3
def create_cursor(conn):
cursor = conn.cursor()
cursor.row_factory = sqlite3.Row
return cursor
def create_db(conn):
cursor = create_cursor(conn)
cursor.execute("""
CREATE TABLE IF NOT EXISTS events
id INTEGER PRIMARY KEY AUTOINCREMENT
name TEXT NOT NULL
description TEXT
start_time DATETIME NOT NULL
length INT NOT NULL
all_day BOOL NOT NULL
date_created DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
""");