summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore (renamed from rust/.gitignore)0
-rw-r--r--.ignore1
-rw-r--r--Cargo.toml (renamed from rust/Cargo.toml)0
-rw-r--r--N (renamed from rust/N)0
-rw-r--r--env_example (renamed from rust/env_example)0
-rw-r--r--python/.gitignore1
-rw-r--r--python/database.py58
-rw-r--r--python/main.py4
-rw-r--r--python/routes.py33
-rw-r--r--rust/.ignore1
-rw-r--r--rust/scripts/create_db.sh11
-rw-r--r--rust/src/routes.rs1
-rw-r--r--scripts/create_db.sh27
-rw-r--r--scripts/create_db.sql (renamed from rust/scripts/create_db.sql)0
-rw-r--r--scripts/create_user.sql (renamed from rust/scripts/create_user.sql)0
-rw-r--r--scripts/populate.sh (renamed from rust/scripts/populate.sh)0
-rw-r--r--scripts/populate/.gitignore (renamed from rust/scripts/populate/.gitignore)0
-rw-r--r--scripts/populate/albums.py (renamed from rust/scripts/populate/albums.py)0
-rw-r--r--scripts/populate/api.py (renamed from rust/scripts/populate/api.py)0
-rw-r--r--scripts/populate/create_db.sql (renamed from rust/scripts/populate/create_db.sql)0
-rw-r--r--scripts/populate/database.py (renamed from rust/scripts/populate/database.py)0
-rw-r--r--scripts/populate/main.py (renamed from rust/scripts/populate/main.py)0
-rw-r--r--scripts/populate/parser.py (renamed from rust/scripts/populate/parser.py)0
-rw-r--r--scripts/populate/structures.py (renamed from rust/scripts/populate/structures.py)0
-rw-r--r--src/main.rs (renamed from rust/src/main.rs)0
-rw-r--r--src/routes.rs0
-rw-r--r--src/routes/hello.rs (renamed from rust/src/routes/hello.rs)0
-rw-r--r--src/structs.rs (renamed from rust/src/structs.rs)0
28 files changed, 28 insertions, 109 deletions
diff --git a/rust/.gitignore b/.gitignore
index 9adab75..9adab75 100644
--- a/rust/.gitignore
+++ b/.gitignore
diff --git a/.ignore b/.ignore
new file mode 100644
index 0000000..2ce903e
--- /dev/null
+++ b/.ignore
@@ -0,0 +1 @@
+scripts/populate/
diff --git a/rust/Cargo.toml b/Cargo.toml
index b4a8000..b4a8000 100644
--- a/rust/Cargo.toml
+++ b/Cargo.toml
diff --git a/rust/N b/N
index a755b9a..a755b9a 100644
--- a/rust/N
+++ b/N
diff --git a/rust/env_example b/env_example
index 607b7cc..607b7cc 100644
--- a/rust/env_example
+++ b/env_example
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
- )
- )
diff --git a/rust/.ignore b/rust/.ignore
deleted file mode 100644
index 0b68341..0000000
--- a/rust/.ignore
+++ /dev/null
@@ -1 +0,0 @@
-# scripts/populate/
diff --git a/rust/scripts/create_db.sh b/rust/scripts/create_db.sh
deleted file mode 100644
index 4e6ebc1..0000000
--- a/rust/scripts/create_db.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/bash
-echo "choose a password for the database:"
-read input
-echo "creating database..."
-sudo mariadb -u root <<EOF
-$(cat scripts/create_user.sql)
-EOF
-
-echo '$input'
-
-sudo mariadb -u root < ./scripts/create_db.sql
diff --git a/rust/src/routes.rs b/rust/src/routes.rs
deleted file mode 100644
index 8cb6ff0..0000000
--- a/rust/src/routes.rs
+++ /dev/null
@@ -1 +0,0 @@
-mod hello;
diff --git a/scripts/create_db.sh b/scripts/create_db.sh
new file mode 100644
index 0000000..c0e759c
--- /dev/null
+++ b/scripts/create_db.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+echo "choose a password for the database:"
+read input
+echo "use xampp's version of mariadb? [y/n]"
+read answer
+
+if [[ $answer == 'y' ]] then
+ mariadb="/opt/lampp/bin/mariadb"
+else
+ mariadb="mariadb"
+fi
+
+echo "use sudo? [y/n]"
+read answer
+
+if [[ $answer == 'y' ]] then
+ sudo="sudo"
+fi
+
+echo "creating database..."
+$sudo $mariadb -u root <<EOF
+$(cat scripts/create_user.sql)
+EOF
+
+echo '$input'
+
+$sudo $mariadb -u root < ./scripts/create_db.sql
diff --git a/rust/scripts/create_db.sql b/scripts/create_db.sql
index f803714..f803714 100644
--- a/rust/scripts/create_db.sql
+++ b/scripts/create_db.sql
diff --git a/rust/scripts/create_user.sql b/scripts/create_user.sql
index bc9472b..bc9472b 100644
--- a/rust/scripts/create_user.sql
+++ b/scripts/create_user.sql
diff --git a/rust/scripts/populate.sh b/scripts/populate.sh
index d8ccf8d..d8ccf8d 100644
--- a/rust/scripts/populate.sh
+++ b/scripts/populate.sh
diff --git a/rust/scripts/populate/.gitignore b/scripts/populate/.gitignore
index 6922c3e..6922c3e 100644
--- a/rust/scripts/populate/.gitignore
+++ b/scripts/populate/.gitignore
diff --git a/rust/scripts/populate/albums.py b/scripts/populate/albums.py
index 63114da..63114da 100644
--- a/rust/scripts/populate/albums.py
+++ b/scripts/populate/albums.py
diff --git a/rust/scripts/populate/api.py b/scripts/populate/api.py
index 5cc24d3..5cc24d3 100644
--- a/rust/scripts/populate/api.py
+++ b/scripts/populate/api.py
diff --git a/rust/scripts/populate/create_db.sql b/scripts/populate/create_db.sql
index cfde7b0..cfde7b0 100644
--- a/rust/scripts/populate/create_db.sql
+++ b/scripts/populate/create_db.sql
diff --git a/rust/scripts/populate/database.py b/scripts/populate/database.py
index 2319812..2319812 100644
--- a/rust/scripts/populate/database.py
+++ b/scripts/populate/database.py
diff --git a/rust/scripts/populate/main.py b/scripts/populate/main.py
index ec0157c..ec0157c 100644
--- a/rust/scripts/populate/main.py
+++ b/scripts/populate/main.py
diff --git a/rust/scripts/populate/parser.py b/scripts/populate/parser.py
index cbb51b5..cbb51b5 100644
--- a/rust/scripts/populate/parser.py
+++ b/scripts/populate/parser.py
diff --git a/rust/scripts/populate/structures.py b/scripts/populate/structures.py
index 31feb1b..31feb1b 100644
--- a/rust/scripts/populate/structures.py
+++ b/scripts/populate/structures.py
diff --git a/rust/src/main.rs b/src/main.rs
index af45779..af45779 100644
--- a/rust/src/main.rs
+++ b/src/main.rs
diff --git a/src/routes.rs b/src/routes.rs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/routes.rs
diff --git a/rust/src/routes/hello.rs b/src/routes/hello.rs
index c356081..c356081 100644
--- a/rust/src/routes/hello.rs
+++ b/src/routes/hello.rs
diff --git a/rust/src/structs.rs b/src/structs.rs
index 7535bb4..7535bb4 100644
--- a/rust/src/structs.rs
+++ b/src/structs.rs