SQL over REST

From MemCP
Jump to navigation Jump to search

There are two methods to do SQL over REST:

a) GET method: curl http://root:admin@localhost:4321/sql/[SCHEMA]/[SQL_QUERY]

b) POST method: curl -X POST -d '[SQL_QUERY]' http://root:admin@localhost:4321/sql/[SCHEMA]

JSONL results

The result is a jsonl document containing the result lines:

curl -X POST -d 'select a, sum(b) as sum_b from a group by a' http://root:admin@localhost:4321/sql/test

returns

{"a": 1, "sum_b": 7}
{"a": 2, "sum_b": 6}
{"a": 6, "sum_b": null}

Custom REST interfaces directly in MemCP

To create your own custom REST endpoints, consider reading about In-Database WebApps