You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
724 B
Python
25 lines
724 B
Python
|
2 months ago
|
# helpers/db_moments.py
|
||
|
|
from typing import List, Dict
|
||
|
|
from config import get_local_db_connection
|
||
|
|
|
||
|
|
def add_moment(video_uuid: str, ts_seconds: int) -> str:
|
||
|
|
conn, cursor = get_local_db_connection()
|
||
|
|
cursor.execute(
|
||
|
|
"INSERT INTO moments (video_id, timestamp) VALUES (%s, %s)",
|
||
|
|
(video_uuid, ts_seconds),
|
||
|
|
)
|
||
|
|
conn.commit()
|
||
|
|
new_id = cursor.lastrowid
|
||
|
|
cursor.close(); conn.close()
|
||
|
|
return new_id
|
||
|
|
|
||
|
|
def list_moments(video_uuid: str):
|
||
|
|
conn, cursor = get_local_db_connection()
|
||
|
|
cursor.execute(
|
||
|
|
"SELECT id, timestamp FROM moments WHERE video_id = %s ORDER BY timestamp ASC",
|
||
|
|
(video_uuid,),
|
||
|
|
)
|
||
|
|
rows = cursor.fetchall()
|
||
|
|
cursor.close(); conn.close()
|
||
|
|
return rows
|