boreal
boreal copied to clipboard
REST interface for MySQL, MariaDB and Aurora servers running in containers! :whale: :snowflake:
REST Provider for MySQL, MariaDB and Amazon Aurora servers running in containers!
RUN
RESTfy a simple MySQL server
$ docker run -e MYSQL_MASTER_SERVER=http://master.rds.com.br \
-e MYSQL_MASTER_USER=root \
-e MYSQL_MASTER_PASS=pass \
-e MYSQL_MASTER_SCHEMA=payments \
-e MYSQL_MASTER_PORT=3306 \
msfidelis/boreal
RESTfy a Master and Read server
$ docker run -e MYSQL_MASTER_SERVER=http://master.rds.com.br \
-e MYSQL_MASTER_USER=root \
-e MYSQL_MASTER_PASS=pass \
-e MYSQL_MASTER_SCHEMA=payments \
-e MYSQL_MASTER_PORT=3306 \
-e MYSQL_READ_SERVER=http://read.rds.com.br \
-e MYSQL_READ_USER=root \
-e MYSQL_READ_PASS=pass \
-e MYSQL_READ_SCHEMA=payments_replica \
-e MYSQL_READ_PORT=3306 \
msfidelis/boreal
RESTFy a MySQL Server and Memcached Server
$ docker run -e MYSQL_MASTER_SERVER=http://master.rds.com.br \
-e MYSQL_MASTER_USER=root \
-e MYSQL_MASTER_PASS=pass \
-e MYSQL_MASTER_SCHEMA=payments \
-e MYSQL_MASTER_PORT=3306 \
-e MEMCACHED_SERVER=http://memcached.com.br \
-e MEMCACHED_PORT=11211 \
msfidelis/boreal
RESTFy a MySQL Server and Redis Server
$ docker run -e MYSQL_MASTER_SERVER=http://master.rds.com.br \
-e MYSQL_MASTER_USER=root \
-e MYSQL_MASTER_PASS=pass \
-e MYSQL_MASTER_SCHEMA=payments \
-e MYSQL_MASTER_PORT=3306 \
-e REDIS_SERVER=http://redis.com.br \
-e REDIS_PORT=6379 \
msfidelis/boreal
SELECT
Select Fields
http://localhost:1337/v1/users?_fields=id:name:age
Output Query:
select `id`, `name`, `age` from `users`
Where Fields
http://localhost:1337/v1/users?_fields=id:name:age&_where=id=12
Output Query:
select `id`, `name`, `age` from `users` where id = 12
http://localhost:1337/v1/users?_fields=id:name:age&_where=id=12 AND age > 12 OR NAME = 'matheus'
Query Output:
select `id`, `name`, `age` from `users` where id = 12
INSERT
INSERT A SINGLE ROW
Request POST
$ curl -X POST \
-H "Content-type: Application/json" \
-d '{ "data" : {"name":"Matheus Fidelis", "age":21}}' \
localhost:1337/v1/users
Output Query
insert into `users` (`age`, `name`) values (21, 'Matheus Fidelis')
INSERT BULK DATA
Request POST
$ curl -X POST \
-H "Content-type: Application/json" \
-d '{ "data" : [{"name":"Matheus Fidelis", "age":21}, {"name":"Dunha", "age":30}]}' \
localhost:1337/v1/users
UPDATE
Request PUT/PATCH
curl -X PUT \
-H "Content-type: Application/json" \
-d '{ "data": {"name":"Matheus Fidelis changed", "age":21}, "where":"id = 12"}' \
localhost:1337/v1/users
Output Query
update `users` set `age` = 21, `name` = 'Matheus Fidelis' where id = 12 and user = `Matheus`
DELETE
curl -X DELETE \
-H "Content-type: Application/json" \
-d '{"where":"id = 12 and name = `Matheus Fidelis`"}' \
localhost:1337/v1/users
Output Query
delete from `users` where id = 12 and user = `Matheus`
RAW QUERY
$ curl -X POST \
-H "Content-type: Application/json" \
-d '{"query":"SELECT * FROM users"}' \
localhost:1337/v1/_QUERY
Output Query
SELECT CONCAT_WS(`,`,`First name`,`Second name`,`Last Name`
ADMINISTRATIVE COMMANDS
FLUSH TABLES
curl -X GET http://localhost:1337/v1/_FLUSHTABLES
RESPONSE
{
"info": {
"query_uuid": "6106fca4-998f-43a9-937f-c0f322846df1",
"sql": "FLUSH TABLES",
"affectedRows": 0
},
"data": [
{
"fieldCount": 0,
"affectedRows": 0,
"insertId": 0,
"serverStatus": 2,
"warningCount": 0,
"message": "",
"protocol41": true,
"changedRows": 0
},
null
]
}
RESET QUERY CACHE
$ curl -X GET http://localhost:1337/v1/_RESETQUERYCACHE
Response
{
"info": {
"query_uuid": "72b50bb8-c1c2-4d00-bf69-0257e805973c",
"sql": "RESET QUERY CACHE",
"affectedRows": 0
},
"data": [
{
"fieldCount": 0,
"affectedRows": 0,
"insertId": 0,
"serverStatus": 2,
"warningCount": 0,
"message": "",
"protocol41": true,
"changedRows": 0
},
null
]
}
FLUSH QUERY CACHE
$ curl -X GET http://localhost:1337/v1/_FLUSHQUERYCACHE
RESPONSE
{
"info": {
"query_uuid": "a1083c56-7f8b-46f9-acf6-9cdbf3ed74c8",
"sql": "FLUSH QUERY CACHE",
"affectedRows": 0
},
"data": [
{
"fieldCount": 0,
"affectedRows": 0,
"insertId": 0,
"serverStatus": 2,
"warningCount": 0,
"message": "",
"protocol41": true,
"changedRows": 0
},
null
]
}
SHOW PROCESSLIST
$ curl -X GET http://localhost:1337/v1/_PROCESSLIST
RESPONSE
{
"info": {
"query_uuid": "9dfdc45b-dfc1-4c05-9533-6a9d524e94e8",
"sql": "SHOW PROCESSLIST"
},
"data": [
[
{
"Id": 46,
"User": "root",
"Host": "172.19.0.1:48240",
"db": "test",
"Command": "Sleep",
"Time": 5685,
"State": "",
"Info": null
},
{
"Id": 47,
"User": "root",
"Host": "172.19.0.1:48242",
"db": null,
"Command": "Sleep",
"Time": 5704,
"State": "",
"Info": null
},
{
"Id": 322,
"User": "root",
"Host": "172.19.0.1:48794",
"db": "test",
"Command": "Sleep",
"Time": 2080,
"State": "",
"Info": null
}
]
...
}
SHOW CREATE TABLE
$ curl -X GET http://localhost:1337/v1/_SHOWCREATE/{table}
RESPONSE
{
"info": {
"query_uuid": "7bf77111-f774-4cdc-89cb-46f183b7d264",
"sql": "SHOW CREATE TABLE users"
},
"data": [
[
{
"Table": "users",
"Create Table": "CREATE TABLE `users` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `name` varchar(50) NOT NULL,\n `age` int(11) NOT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=latin1"
}
]
]
...
}
DESCRIBE TABLE
$ curl -X GET http://localhost:1337/v1/_DESCRIBE/users
{
"info": {
"query_uuid": "f5f8a6ae-f9c1-4a6d-b304-15f0a3eedd05",
"sql": "DESCRIBE users"
},
"data": [
[
{
"Field": "id",
"Type": "int(11)",
"Null": "NO",
"Key": "PRI",
"Default": null,
"Extra": "auto_increment"
},
{
"Field": "name",
"Type": "varchar(50)",
"Null": "NO",
"Key": "",
"Default": null,
"Extra": ""
},
{
"Field": "age",
"Type": "int(11)",
"Null": "NO",
"Key": "",
"Default": null,
"Extra": ""
}
]
...
}
SHOW TABLES
$ curl -X GET http://localhost:1337/v1/_SHOWTABLES
RESPONSE
{
"info": {
"query_uuid": "1b0a3fc0-81a8-4d15-8c71-d96b9ca9ebbb",
"sql": "SHOW TABLES\t"
},
"data": [
[
{
"Tables_in_test": "users"
}
],
[
{
"catalog": "def",
"db": "information_schema",
"table": "TABLE_NAMES",
"orgTable": "TABLE_NAMES",
"name": "Tables_in_test",
"orgName": "TABLE_NAME",
"charsetNr": 33,
"length": 192,
"type": 253,
"flags": 1,
"decimals": 0,
"zeroFill": false,
"protocol41": true
}
]
]
}