madlib 集成 hasura graphql-engine 试用
madlib 可以让我们直接在sql 中进行机器学习,集成了强大的sql 能力,以及分析能力,后边会尝试
集成graphql engine ,让功能更强大
docker 镜像准备
使用了一个别人的写好的,也可以参考官方提供的,就是镜像包有点大
- docker-compose 文件
version: '2'
services:
db:
container_name: madlib-postgres
build:
context: .
dockerfile: postgres/Dockerfile
environment:
- PG_MODE=primary
- PG_PRIMARY_USER=postgres
- PG_PRIMARY_PASSWORD=postgres
- PG_DATABASE=sample
- PG_USER=user
- PG_PASSWORD=user
- PG_ROOT_PASSWORD=root
- PG_PRIMARY_PORT=5432
restart: always
ports:
- 5432:5432
adminer:
image: adminer
restart: always
ports:
- 8080:8080
depends_on:
- db
graphql-engine:
image: hasura/graphql-engine:v1.0.0-alpha30
ports:
- "9090:8080"
depends_on:
- db
environment:
- "POSTGRES_PASSWORD:postgres"
command: >
/bin/sh -c "
graphql-engine --database-url postgres://postgres:root@db:5432/sample serve --enable-console;
"
networks:
default:
driver: bridge
ipam:
driver: default
config:
- subnet: 180.16.0.0/16
gateway: 180.16.0.1
- madlib pg dockerfile
FROM crunchydata/crunchy-postgres:centos7-10.5-2.1.0
USER root
RUN yum -y update; yum clean all
RUN yum -y install postgresql10-plpython supervisor; yum clean all
### Get postgres specific add-ons
RUN yum update -y && yum install -y \
git \
gcc \
wget \
postgresql10-devel \
openssl \
m4 \
vim \
flex \
bison \
graphviz \
java \
epel-release \
python-devel
RUN yum install -y python-pip
ENV PATH="$PATH:/usr/pgsql-10/bin"
RUN pip install awscli pygresql paramiko --upgrade
RUN mkdir -p /src/madlib
COPY ./data/apache-madlib-1.15.1-bin-Linux.rpm /src/madlib
RUN yum install -y /src/madlib/apache-madlib-1.15.1-bin-Linux.rpm --nogpgcheck
USER 26
EXPOSE 5432
CMD ["/opt/cpm/bin/start.sh"]
启动&&初始化环境
- 启动
docker-compose build && docker-compose up -d
- 初始化
docker-compose exec db bash
/usr/local/madlib/bin/madpack -p postgres -c postgres/root@localhost:5432/sample install
/usr/local/madlib/bin/madpack -p postgres -c postgres/root@localhost:5432/sample install-check
- 访问
默认账户信息为 postgres root sample
- 添加一个简单的数据函数测试
创建表
CREATE TABLE array_tbl (
id integer,
array1 integer[],
array2 integer[]
);
添加数据
INSERT INTO "public"."array_tbl"("id","array1","array2")
VALUES
(1,E'{1,2,3,4,5,6}',E'{6,5,4,3,2,1}'),
(2,E'{1,1,0,0,99,8}',E'{0,0,0,-5,2,1}');
使用数组函数:
说明:主要使用了madlib 的数组最大以及最小函数
select id,madlib.array_min(array1) min, madlib.array_max(array1) max from array_tbl
结果 
graphql 引擎使用
- 打开地址
http://localhost:9090
效果 
- 集成
为了方便使用计算的结果,我们使用了试图进行扩展
- 查询madlib 的结果数据

说明
这个只是简单的试用,试用上madlib 的功能还是很强大的,同时对于graphql engine 的扩展,我们有好多种
方法,这个只是一种简单的方式,但同时也无法使用强大的weebhook 等功能了(view 的原因)
参考资料
https://github.com/rongfengliang/docker-madlib
madlib 集成 hasura graphql-engine 试用的更多相关文章
- hasura graphql server event trigger 试用
hasura graphql server 是一个很不错的graphql 引擎,当前版本已经支持event triiger 了 使用此功能我们可以方便的集成webhook功能,实现灵活,稳定,快捷的消 ...
- hasura graphql server 集成gatsby
hasura graphql server 社区基于gatsby-source-graphql 开发了gatsby-postgres-graphql 插件, 可以快速的开发丰富的网站 基本使用 安装h ...
- 通过torodb && hasura graphql 让mongodb 快速支持graphql api
torodb 可以方便的将mongo 数据实时同步到pg,hasura graphql 可以方便的将pg 数据暴露为graphql api,集成在一起真的很方便 环境准备 docker-compose ...
- hasura graphql subscriptions 使用
subscriptions graphql 的一项实时数据推送的功能,还是很方便的,自己在直接使用subscriptions-transport-ws npm 包 的时候运行一直有错误(主要是依赖 ...
- Hasura GraphQL schema 生成是如何工作的
不像大部分的graphql 引擎,使用标准的graphql 规范的处理模型,Hasura graphql 不存在resolver 的概念(实际上是有的,只是转换为了sql语法) 以下是Hasura g ...
- hasura graphql auth-webhook api 说明
hasura graphql 生产的使用是推荐使用webhook 进行角色访问控制的,官方同时提供了一个nodejs 的简单demo 代码 git clone https://github.com/h ...
- hasura graphql pg 自定义函数的使用
hasura graphql 的安装可以参考相关项目 创建函数 数据表创建 CREATE TABLE sql_function_table ( id SERIAL PRIMARY KEY, inp ...
- hasura graphql server 集成gitlab
默认官方是提供了gitlab 集成的demo的,但是因为gitlab 一些版本的问题, 跑起来总有问题,所以查找相关资料测试了一个可以运行的版本 项目使用docker-compose 运行 参考 ht ...
- hasura graphql 集成pipelinedb测试
实际上因为pipelinedb 是原生支持pg的,所以应该不存在太大的问题,以下为测试 使用doker-compose 运行 配置 docker-compose 文件 version: '3.6' s ...
随机推荐
- Android开发 ---如何操作资源目录中的资源文件5 ---Raw资源管理与国际化
效果图: 1.activity_main.xml 描述: 定义两个按钮,一个是Raw资源管理,一个是处理国际化语言,其中i18n表示简体中文 <?xml version="1.0&qu ...
- Centos7部署kubernetes-ETCD集群(三)
1.下载etcd软件包 wget https://github.com/coreos/etcd/releases/download/v3.2.18/etcd-v3.2.18-linux-amd64.t ...
- socket-重叠模型(overlap)
socket-重叠模型(overlap) 重叠模型的基本设计原理便是让应用程序使用一个重叠的数据结构,一次投递一个或多个Winsock I/O请求.针对那些提交的请求,在它们完成之后,应用程序可为它们 ...
- 201621123001 《Java程序设计》第7周学习总结
1. 本周学习总结 1.1 思维导图:Java图形界面总结 1.2 可选:使用常规方法总结其他上课内容. 掌握了NetBeans基本使用方法 掌握布局管理器基本概念 尝试了自己在界面布置组件 网格组布 ...
- go语言基础学习
go基础学习,面向对象-方法在Go语言中,可以给任意自定义类型(包括内置类型,但不包括指针类型)添加相应的方法 使用= 和:=的区别: // = 使用必须使用先var声明例如: var a a=100 ...
- 火狐下,td 的 bug;
想实现类似的效果,看代码, <div style="width:488px;float:left; margin:-52px 0px 15px 15px;"> < ...
- linux 部署之路 修行不够全靠悟
考虑到很多孩子不会Linux或Mysql,所以我这里提示一下, 这篇教程里 "有多行代码" 的是给你展示结果的,不用你敲 只有一行的才是要你自己敲进去的. 1.首先更新一下仓库 ...
- make clean,make distclean与make depend的区别
make clean仅仅是清除之前编译的可执行文件及配置文件. 而make distclean要清除所有生成的文件. Makefile 在符合GNU Makefiel惯例的Makefile中,包含了一 ...
- 【linux基础】CMake如何生成动态链接库文件
CMakeLists.txt SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib) ADD_LIBRARY(filename SHARED ${CURREN ...
- AI之路,第二篇:python数学知识2
第二篇:python数学知识2 线性代数 导入相应的模块: >>> import numpy as np (数值处理模块)>>> import scipy ...