修改密码

请输入密码
请输入密码 请输入8-64长度密码 和 email 地址不相同 至少包括数字、大写字母、小写字母、半角符号中的 3 个
请输入密码
提交

修改昵称

当前昵称:
提交

申请证书

证书详情

Please complete this required field.

  • Ultipa Graph V4

Standalone

Please complete this required field.

Please complete this required field.

服务器的MAC地址

Please complete this required field.

Please complete this required field.

取消
申请
ID
产品
状态
核数
申请天数
审批时间
过期时间
MAC地址
申请理由
审核信息
关闭
基础信息
  • 用户昵称:
  • 手机号:
  • 公司名称:
  • 公司邮箱:
  • 地区:
  • 语言:
修改密码
申请证书

当前未申请证书.

申请证书
Certificate Issued at Valid until Serial No. File
Serial No. Valid until File

Not having one? Apply now! >>>

ProductName CreateTime ID Price File
ProductName CreateTime ID Price File

No Invoice

v5.0
搜索
    v5.0

      导入关系型数据库

      本文介绍如何将数据从关系型数据库导入嬴图数据库。

      嬴图Transporter支持在sql模式下使用统一配置文件,从MySQL、PostgreSQL、SQL Server、Oracle和Snowflake导入数据。
      以下步骤均在Windows系统上的PowerShell和MySQL中演示。

      生成配置文件

      打开终端程序,导航至ultipa-importer所在文件夹。执行以下命令,选择sql,为导入关系型数据库数据生成样本配置文件:

      ./ultipa-importer --sample
      

      执行命令后,会在ultipa-importer所在目录下生成配置文件import.sample.sql.yml。如果目录下已有该文件,数据将被覆盖。

      修改配置文件

      根据实际使用场景修改import.sample.sql.yml文件。该文件包含以下部分:

      • mode:设置为sql
      • sqlDatabase:配置SQL数据库连接,包括连接驱动、数据源名称(DSN)和服务器详情。
      • server:提供嬴图服务器信息,并为数据导入指定目标图(新图或已有图)。
      • nodeConfig:定义点schema,其中每个schema对应一个查询结果。查询结果中的各列将映射为点属性。
      • edgeConfig:定义边schema,其中每个schema对应一个查询结果。查询结果中的各列将映射为边属性。
      • settings:为数据导入设置全局参数和偏好。

      # 导入模式:csv/json/jsonl/rdf/graphml/bigQuery/sql/kafka/neo4j/salesforce
      mode: sql
      
      # SQL服务器配置
      sqlDatabase:
        # Driver:mysql/postgreSQL/sqlserver/snowflake/odbc/oracle
        driver: "mysql"
        # dsn:如果提供了数据源名称(DSN),将忽略其他设置(host/port/dbname/username/password)
        ## mysql dsn: "<username>:<password>@tcp(<host>:<port>)/<dbname>?net_write_timeout=6000"
        ## postgreSQL dsn: "user=<username> dbname=<dbname> password=<password> host=<host> port=<port> sslmode=disable"
        ## sqlserver dsn: "server=<host>,<port>;user id=<username>;password=<password>;database=<dbname>"
        # snowflake dsn: "<username>:<password>@<orgname>-<account_name>/<db_name>/<schema_name>?warehouse=<warehouse_name>"
        ## odbc dsn: "DSN=<dsn>;UID=<username>;PWD=<password>"
        ## oracle dsn: "oracle://<username>:<password>@<host>:<port>/<dbname>"
        dsn: ""
        # 主机IP/URI
        host: "192.168.1.88"
        port: "3306"
        dbname: "trading"
        username: "root"
        password: "root"
      
      # 嬴图服务器配置
      server:
        # 主机IP/URI和端口;若为集群,使用英文逗号分隔
        host: "10.11.22.33:1234"
        username: "admin"
        password: "admin12345"
        # 目标图(新图或已有图)
        graphset: "myGraph"
        # 若上图为新图,指定图所在分片
        shards: "1,2,3"
        # 若上图为新图,指定分片分区算法(Crc32/Crc64WE/Crc64XZ/CityHash64)
        partitionBy: "Crc32"
        # TLS加密证书文件路径
        crt: ""
      
      # 点配置
      nodeConfig:
        # 指定schema
        - schema: "Customer"
          # 获取所需数据的SQL查询语句
          sql: "SELECT * FROM Customer"
          # properties:将查询结果中的各列映射为属性;若未设置,将自动映射所有列
          ## name:查询结果中的列名
          ## new_name:属性名;默认为上述名称
          ## type:属性类型;可设置为_id,_from,_to或其他嬴图属性,如int64,float,string等:设置为_ignore时可跳过导入该列
          ## prefix:为属性值增加前缀;仅适用于_id,_from和_to类型
          properties:
            - name: cust_no
              new_name: _id
              type: _id
              prefix:
            - name: name
              type: string
            - name: level
              type: int32
        - schema: "Merchant"
          sql: "SELECT * FROM Merchant"
          properties:
            - name: merch_no
              type: _id
            - name: name
              type: string
            - name: type
              type: string
      
      # 边配置
      edgeConfig:
        - schema: "Transfers"
          sql: "SELECT * FROM Transaction"
          # _from和_to为边的必需类型
          properties:
            - name: trans_no
              type: string
            - name: cust_no
              type: _from
            - name: merch_no
              type: _to
            - name: time
              type: datetime
      
      # 全局设置     
      settings:
       # 日志文件路径
        logPath: "./logs"
        # 每批次导入的点或边的数量
        batchSize: 10000
        # 插入模式:insert/overwrite/upsert
        importMode: insert
        # 插入边时,自动创建缺失端点
        createNodeIfNotExist: false
        # 报错时停止数据导入
        stopWhenError: false
        # 设置为true时,自动创建新的图、schema和属性
        yes: true
        # 最大线程数
        threads: 32
        # RPC最大消息传输量(单位:MB)
        maxPacketSize: 40
        # 时间戳对应时区
        # 默认时区:"+0200"
        # 时间戳单位,支持毫秒(ms)或秒(s)
        timestampUnit: s
      

      执行导入

      使用--config标志指定配置文件,执行数据导入:

      ./ultipa-importer --config import.sample.sql.yml
      
      请完成以下信息后可下载此书
      *
      公司名称不能为空
      *
      公司邮箱必须填写
      *
      你的名字必须填写
      *
      你的电话必须填写
      *
      你的电话必须填写