From 0972fa6eab8c9111311f082ba8abfdc6b4a40945 Mon Sep 17 00:00:00 2001 From: nil Date: Wed, 2 Oct 2024 17:48:56 +0200 Subject: commit changes --- python/.gitignore | 1 - python/database.py | 58 ------------------------------------------------------ python/main.py | 4 ---- python/routes.py | 33 ------------------------------- 4 files changed, 96 deletions(-) delete mode 100644 python/.gitignore delete mode 100644 python/database.py delete mode 100644 python/main.py delete mode 100644 python/routes.py (limited to 'python') diff --git a/python/.gitignore b/python/.gitignore deleted file mode 100644 index c18dd8d..0000000 --- a/python/.gitignore +++ /dev/null @@ -1 +0,0 @@ -__pycache__/ 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() diff --git a/python/main.py b/python/main.py deleted file mode 100644 index d7eb1b6..0000000 --- a/python/main.py +++ /dev/null @@ -1,4 +0,0 @@ -import routes - - -routes.app.run() diff --git a/python/routes.py b/python/routes.py deleted file mode 100644 index 9567318..0000000 --- a/python/routes.py +++ /dev/null @@ -1,33 +0,0 @@ -from flask import Flask, jsonify, request -import database - - -app = Flask(__name__) - - -def run(): - app.run() - - -@app.route("/", methods=['GET']) -def hello_world(): - return "not here" - - -@app.route("/song", methods=['GET']) -def get_song(): - id = request.args.get('id') - name = request.args.get('name') - return jsonify(database.get_song(id=id, name=name)) - - -@app.route("/songs", methods=['GET']) -def get_filtered_songs(): - song = request.args.get('song') - album = request.args.get('album') - artist = request.args.get('artist') - return jsonify( - database.get_filtered_songs( - song=song, album=album, artist=artist - ) - ) -- cgit v1.2.3