JSON-RPC interface for postgresql database stored procedures
841
This service
http://hostname/api/function?arg1=val1&arg2=val2
CREATE FUNCTION function(arg1 TYPE, arg2 TYPE) RETURNS SETOF ...
select * from function(arg1 := val1, arg2 := val2)
curl "http://localhost:8081/api/public.echo?id=1&name=op" | jq "."
{
"result": [
{
"name": "op",
"id": 1
}
],
"success": true
}
Also, the same functionality may be used via JSON-RPC interface
--index arg - proc name to fetch functions list (and name -> function mapping)for q := range "select * from cron_func(stamp)" { select * from q(stamp) }Declaration:
SELECT ws.register_comment(
'echo_arr'
,'тест массива'
,'{"a_name":"массив","a_id":"число"}'
,'{"name":"массив","id":"число"}'
,''
);
CREATE OR REPLACE FUNCTION echo_arr(
a_name TEXT[]
, a_id INTEGER DEFAULT 5
) RETURNS TABLE(name TEXT[], id INTEGER) LANGUAGE 'sql' AS
$_$
SELECT $1, $2;
$_$;
Calls:
curl -gs 'http://localhost:8081/rpc/echo_arr?a_id=107050&a_name=2&a_name=3'
{
"success": true,
"result": [
{
"id": 107050,
"name": [
"2",
"3"
]
}
]
}
curl -gs 'http://localhost:8081/rpc/echo_arr?a_id=107050&a_name=2,3'
{
"success": true,
"result": [
{
"id": 107050,
"name": [
"2",
"3"
]
}
]
}
go get github.com/LeKovr/dbrpc
See Latest release
See pgrpc-sql-rpc
The MIT License (MIT), see LICENSE.
Copyright (c) 2016 Alexey Kovrizhkin [email protected]
Content type
Image
Digest
Size
3.6 MB
Last updated
about 9 years ago
docker pull lekovr/dbrpc