标签:upd work user number 准备 roo 数组函数 方便 函数
madlib 可以让我们直接在sql 中进行机器学习,集成了强大的sql 能力,以及分析能力,后边会尝试
集成graphql engine ,让功能更强大
使用了一个别人的写好的,也可以参考官方提供的,就是镜像包有点大
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
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
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
结果
http://localhost:9090
效果
这个只是简单的试用,试用上madlib 的功能还是很强大的,同时对于graphql engine 的扩展,我们有好多种
方法,这个只是一种简单的方式,但同时也无法使用强大的weebhook 等功能了(view 的原因)
https://github.com/rongfengliang/docker-madlib
madlib 集成 hasura graphql-engine 试用
标签:upd work user number 准备 roo 数组函数 方便 函数
原文地址:https://www.cnblogs.com/rongfengliang/p/10290164.html