cratedb provides compatible pg agreement, we can use directly pg client connections, but it is not a complete implementation of the agreement pg
Here are some to try cube.js of integrated cratedb
Preparing the Environment
- docker-compose documents
The main database environment
version: "3"
services:
db:
image: crate
ports:
- "5432:5432"
- "4200:4200"
- cube.js pg project creation
cubejs create -d postgres cratedemo
- Modify environment variables cube
CUBEJS_DB_HOST=127.0.0.1
CUBEJS_DB_USER=crate
CUBEJS_DB_TYPE=postgres
CUBEJS_API_SECRET=c35c282663b0ba7918ad48740ab7bb326bcb733b97b0b5f434ba188c685b8dffbfb47c9ad37650643ff24ebffdc618255f967f60a6a50bd1d189692f14e76fe0
schema generation attempts
- Start cratedb
docker-compose up -d
effect
- Start cube dev
yarn dev
Error message:
Description:
The main cube pg driver is used cratedb command code is not supported in the time zone of the following process:
Solution:
temporary delete the processing of set time zone
- Restart dev
yarn dev
Effect (well, schema may appear a)
- Create a table (by admin ui)
create table userapps (id int,appname text,appversion text,flags boolean);
Refresh cube dev (created table schema appeared)
- Generating schema
- Insert data
insert into userapps(id,appname,appversion,flags) values(1,'login','1.0',true);
insert into userapps(id,appname,appversion,flags) values(2,'logo','1.0',true);
insert into userapps(id,appname,appversion,flags) values(3,'market','1.0',true);
- 简单数据报表生成
说明
以上就是一个简单cube.js 集成cube.js 的尝试,更好的做法是修改代码,调整为一个标准的driver(npm 包),同时按照官方的约定,最好还是pr
因为对于driver 的依赖是代码固定好的,如下: