diff options
author | nil <nil@tfwhyno.gf> | 2024-10-02 17:48:56 +0200 |
---|---|---|
committer | nil <nil@tfwhyno.gf> | 2024-10-02 17:48:56 +0200 |
commit | 0972fa6eab8c9111311f082ba8abfdc6b4a40945 (patch) | |
tree | 4eedbdc1a7cfdeee9d651c9871a9f26ab6da56d4 /python/database.py | |
parent | 012c2c03b29a987ca4eead023ded22e01aa7477b (diff) |
commit changes
Diffstat (limited to 'python/database.py')
-rw-r--r-- | python/database.py | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/python/database.py b/python/database.py deleted file mode 100644 index 06f5d61..0000000 --- a/python/database.py +++ /dev/null @@ -1,58 +0,0 @@ -import mysql.connector - - -connector = mysql.connector.connect( - host="localhost", - user="root", - database="balalaika", -) - -cursor = connector.cursor() - - -def get_song(id, name): - if id is None: - id = "%" - - if name is None: - name = "%" - - cursor.execute( - """ - select * from song - where id like %(id)s - and name like %(name)s; - """, - { - 'id': id, - 'name': name, - } - ) - - return cursor.fetchall() - - -def get_filtered_songs(song, album, artist): - if artist is None: - artist = "%" - - if album is None: - album = "%" - - cursor.execute( - """ - select song.name, album.name, artist.name - from song - inner join album on song.album_id=album.id - inner join artist on album.artist_id=artist.id - where artist.name like %(artist)s - and album.name like %(album)s; - """, - { - 'artist': artist, - 'album': album, - 'song': song, - } - ) - - return cursor.fetchall() |