QueryDB is a microservice, that gets query and exports the query's results to a CSV file.
- Docker
- cURL
-
Use
git clone https://github.com/orbarilan4/querydb.git
to clone a repository into a new directory. -
Put
config.conf
(your jdbc configuration file) inquerydb
dir (aside to theDockerfile
).
The file should look like:jdbc { url = "jdbc:mysql://mydb.net/querydbtest" username = "username" password = "password" }
-
Go to
querydb
dir by doing the command:
cd querydb
- Create
shadowJar
with the command:
gradlew sJ
- Build an image from the Dockerfile:
docker build -t my-dockerized-java-app:v1 .
- Create and start container:
docker run --mount type=bind,source="Your-Output-File-Path",target=/output -p 8080:8080 --name webserver my-dockerized-java-app:v1
The Microservice request body will be as follow:
{
"query" : "select * from table where id > 3"
"fileName" : "testdata.csv"
}
Then the cURL command should look like:
curl -H "Content-type: application/json" -X POST -d '{"query": "select * from table where id > 3","fileName":" testdata.csv"}' http://localhost:8080/