mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
set up track logging
+ install flask restful
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
from app.db.sqlite.utils import SQLiteManager
|
||||
import time
|
||||
|
||||
|
||||
class SQLiteTrackLogger:
|
||||
@classmethod
|
||||
def insert_track(cls, trackhash: str, duration: int, source: str):
|
||||
"""
|
||||
Inserts a track into the database
|
||||
"""
|
||||
|
||||
with SQLiteManager(userdata_db=True) as cur:
|
||||
sql = """INSERT OR REPLACE INTO track_logger(
|
||||
trackhash,
|
||||
duration,
|
||||
timestamp,
|
||||
source,
|
||||
userid
|
||||
) VALUES(?,?,?,?,?)
|
||||
"""
|
||||
timestamp = int(time.time())
|
||||
|
||||
cur.execute(sql, (trackhash, duration, timestamp, source, 0))
|
||||
lastrowid = cur.lastrowid
|
||||
|
||||
return lastrowid
|
||||
Reference in New Issue
Block a user