从PostgreSQL数据库test中获取表entity和relation的数据,导入至嬴图数据库的图集shareholding中:
1. 生成配置文件模板
./ultipa-importer --sample
2. 修改配置文件
# 配置数据源类型
mode: postgreSQL
# 配置数据源信息
sqlDatabase:
host: "192.168.1.1"
port: "5432"
dbname: "test"
username: "admin"
password: "abcd1234"
# 配置嬴图服务器
server:
# 嬴图服务器,集群中的多个节点用英文逗号隔开
host: "192.168.2.149:60075"
username: "admin"
password: "abcd1234"
# 图集名,默认使用图集default
graphset: "shareholding"
# 用于远程通信的ssl证书文件的路径及名称,仅在双方均为ssl模式时有效
crt: ""
# 配置点数据的字段
nodeConfig:
- schema: "human"
sql: "select id, name from entity where type = 1"
properties:
- name: id
type: _id
- name: name
type: string
- schema: "firm"
sql: "select id, name from entity where type = 3"
properties:
- name: id
type: _id
- name: name
type: string
# 配置边数据的字段
edgeConfig:
- schema: "hold"
sql: "select from, to, shareInt from relation where type = 'holding'"
properties:
- name: from
type: _from
- name: to
type: _to
- name: shareInt
type: int32
new_name: share
# 全局设置
settings:
batchSize: 10000
importMode: insert
# 自动创建图集、schema和属性
yes: true
3. 执行导入
./ultipa-importer --config ./import.sample.postgreSQL.yml