pipelinedb 是一个基于pg数据库开发的stream sql 数据库,和prisma 集成起来可以开发很
方便的stream 应用
使用docker 安装
项目初始化
- prisma init
注意选择数据库类型为pg
prisma init
- 修改模板配置
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.13
restart: always
ports:
- "4466:4466"
environment:
PRISMA_CONFIG: |
port: 4466
# uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
# managementApiSecret: my-secret
databases:
default:
connector: postgres
host: pipelinedb
port: 5432
user: pipeline
password: pipeline
migrations: true
pipelinedb:
image: tkanos/pipelinedb_kafka
ports:
- "5432:5432"
- 初始化数据库
需要添加prisma 数据库,可以通过pg 客户端进行创建,用户密码 pipeline pipeline
- 启动
docker-compose up -d
- deploy service
prisma deploy
效果
schema
query
mutation
数据库
pipeliendb 简单使用
- 创建stream
CREATE STREAM stream_test1 (x integer, y integer,z text);
- 创建 CONTINUOUS
CREATE CONTINUOUS VIEW v_sum as select sum( x + y ) FROM stream_test1;
CREATE CONTINUOUS VIEW V_GROUP AS SELECT count(*) as coun,x,y,z FROM stream_test1 GROUP BY x,y,z;
- 插入数据
INSERT INTO stream_test1(x,y,z) VALUES(1,2,'A'),(3,4,'B'),(5,6,'C'),(7,8,'D'),(1,2,'A');
- 查询
select * from v_sum;
select * from v_group;
- 效果
说明
pipelinedb 的stream 特性是一个很不错的功能,实际上集成hasura 的graphql 引擎可能会更方便,后边会有相关的测试集成
参考资料
https://www.pipelinedb.com/
https://github.com/rongfengliang/prisma-pipelinedb-demo