SQL over REST: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 12: | Line 12: | ||
{"a": 2, "sum_b": 6} |
{"a": 2, "sum_b": 6} |
||
{"a": 6, "sum_b": null} |
{"a": 6, "sum_b": null} |
||
+ | |||
+ | == PostgreSQL Syntax Mode == |
||
+ | To use the postgresql syntax mode, just use other REST endpoints: |
||
+ | |||
+ | a) GET method: <code>curl <nowiki>http://root:admin@localhost:4321/psql/</nowiki>[SCHEMA]/[SQL_QUERY]</code> |
||
+ | |||
+ | b) POST method: <code>curl -X POST -d '[SQL_QUERY]' <nowiki>http://root:admin@localhost:4321/psql/</nowiki>[SCHEMA]</code> |
||
== Custom REST interfaces directly in MemCP == |
== Custom REST interfaces directly in MemCP == |
Latest revision as of 19:11, 20 November 2024
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}
PostgreSQL Syntax Mode
To use the postgresql syntax mode, just use other REST endpoints:
a) GET method: curl http://root:admin@localhost:4321/psql/[SCHEMA]/[SQL_QUERY]
b) POST method: curl -X POST -d '[SQL_QUERY]' http://root:admin@localhost:4321/psql/[SCHEMA]
Custom REST interfaces directly in MemCP
To create your own custom REST endpoints, consider reading about In-Database WebApps