from folkugat_web.dal.sql import Connection, get_connection


def create_db(con: Connection | None = None):
    with get_connection(con) as con:
        create_sessions_table(con)


def create_sessions_table(con: Connection):
    query = """
      CREATE TABLE IF NOT EXISTS sessions (
        id INTEGER PRIMARY KEY,
        date TEXT NOT NULL,
        start_time TEXT NOT NULL,
        end_time TEXT NOT NULL,
        venue_name TEXT,
        venue_url TEXT,
        is_live BOOLEAN DEFAULT false
    )
    """
    cur = con.cursor()
    _ = cur.execute(query)
