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 ...
随机推荐
- 用Python的导入csv、文本文件、Excel文件的数据
使用read_csv函数导入CSV文件 read.csv函数语法 read_csv(file,encoding) 例子: Age,Name 22,wangwei 23,lixin 24,liqing ...
- 如何使用VSTO自动将Excel中的图表复制到Word
如何使用VSTO自动将Excel中的图表复制到Word 原文地址:https://code.msdn.microsoft.com/How-to-copy-Chart-in-Excel-a29f9029 ...
- jdk8-stream的api
1.stream流的概念 1.流的创建 //1. 创建 Stream @Test public void test1(){ //1. Collection 提供了两个方法 stream() 与 par ...
- python获取代理IP
利用requests库获取代理,用Beautiful库解析网页筛选ip # -*- coding: utf- -*- import requests from bs4 import Beautiful ...
- box-shadow 边框阴影
box-shadow: 0 0 20px #000 inset;
- synchronized(二)
package com.bjsxt.base.sync002;/** * 关键字synchronized取得的锁都是对象锁,而不是把一段代码(方法)当做锁, * 所以代码中哪个线程先执行synchro ...
- 对象存储到session中
以前在使用java开发中,通常都是在session里面存放的对象.在使用php开发中,也打算在session中存入对象,确实能把对象放进去,也能把整个对象输出,但就是取不出对象里面的属性. 通过pri ...
- Delphi 10.3.1 TNetHttpClient在多线程中存在的问题及解决方法。
Delphi 10.3.1发布了,对10.3.0存在的各种问题,做了大量的修正.但听高勇说TNetHttpClient在多线程中存在问题,今天做了一下测试,确实如此,看来,还需要官方进一步修正! 具体 ...
- Java学习笔记24(Map集合)
Map接口: Map接口与Collection接口无继承关系. 区别:Collection中的元素是孤立的,一个一个存进去的. Map作为一个映射集合,每一个元素包含Key-value对(键-值对). ...
- 行为参数化和Lambda表达式
行为参数化是指拿出一个代码块把他准备好却不执行它.这个代码块以后可以被程序的其他部分调用,意味着你可以推迟这块代码的执行.方法接受多种行为作为参数,并在内部使用来完成不同的行为.行为参数话的好处在于可 ...