暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

postgrest学习

原创 多米爸比 2019-12-24
2207

1.What is PostgREST

PostgreSQL+ RESTful

2.下载解压

$ wget https://github.com/PostgREST/postgrest/releases/download/v6.0.2/postgrest-v6.0.2-centos7.tar.xz
$ xz -d postgrest-v6.0.2-centos7.tar.xz
$ tar -xvf postgrest-v6.0.2-centos7.tar

3.编辑配置文件 db.conf

db-uri = "postgres://flylinker:123456@127.0.0.1:5555/flylinker"
db-schema = "public"
db-anon-role = "flylinker"
server-host = "0.0.0.0"
server-port = 6666

4.启动postgrest服务监听6666端口

$ ./postgrest db.conf
Attempting to connect to the database...
Listening on port 6666
Connection successful

5.创建测试表并插入数据

create table test (
 id serial primary key,
 info text,
 ctime timestamptz
);

insert into test (info,ctime) values ('佩奇',now()), ('乔治',now());

6.使用postman测试

1.png

2.png

3.png

7.查询规则

http://192.168.99.200:6666/test?select=id,info,ctime&id=eq.2&order=id.desc&limit=2

url中包含表名?select=字段名1,字段名2&过滤条件字段=比较运算符.值&order=排序字段.正序&limit=数量

更多运算操作符 http://postgrest.org/en/latest/api.html#operators

最后修改时间:2022-10-22 13:20:23
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论