From b0be25aafb41d9274f017d845312bb5d7e04869b Mon Sep 17 00:00:00 2001 From: panzerotto Date: Fri, 1 Aug 2025 19:02:50 +0200 Subject: [PATCH] add db --- backend/src/connect.py | 6 ++++++ backend/src/song.py | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 backend/src/connect.py diff --git a/backend/src/connect.py b/backend/src/connect.py new file mode 100644 index 0000000..12e53d8 --- /dev/null +++ b/backend/src/connect.py @@ -0,0 +1,6 @@ +import sqlite3 + + +def get_connection(): + conn = sqlite3.connect("jukebox.db") + return conn diff --git a/backend/src/song.py b/backend/src/song.py index 5ad3115..2260838 100644 --- a/backend/src/song.py +++ b/backend/src/song.py @@ -1,4 +1,22 @@ from dataclasses import dataclass +from connect import get_connection + + +def init_db(): + conn = get_connection() + cursor = conn.cursor() + cursor.execute(""" + CREATE TABLE IF NOT EXISTS songs ( + mbid TEXT PRIMARY KEY, + title TEXT NOT NULL, + artist TEXT NOT NULL, + tags TEXT NOT NULL, + lastfm_image_id TEXT NOT NULL, + youtube_id TEXT NOT NULL + ); + """) + conn.commit() + conn.close() @dataclass