Giter Site home page Giter Site logo

dbinsert's Introduction

Features

  • 快速批量插入
  • 通过 schmea 自定义表结构,内置多种 schema
  • 根据字段类型自动生成数据
  • 快速生成多个库

Support

Install

Releases 下载,或者如果有 go 环境:

go install github.com/vczyh/dbinsert@latest
dbinsert version

Schema

schema 定义了表结构,不同的数据库会有不同,但对于关系数据库大体相同,可以使用 --schema 指定内置或者自定义 schema ,如果不指定则使用默认 schema

支持 schema 的数据库:

  • MySQL
  • PostgreSQL

MySQL

MySQL Schema

[
  {
    // 数据库名称
    "database": "dbinsert",
    // 表名称
    "table": "tbl",
    // 插入 10000 条数据
    "size": 10000,
    // 主键
    "primaryKeyFieldNames": [
      "id"
    ],
    // 所有列
    "fields": [
      {
        "name": "id",
        "type": "INT",
        // 是否自增
        "autoIncrement": true
      },
      {
        "name": "name",
        "type": "CHAR(60)"
      }
    ]
  },
  // ... 
]

内置 schema

Usage

dbinsert mysql \
  --host x.x.x.x \ 
  --port 3306 \
  --user xxx  \
  --password xxx \
  --create-databases \
  --create-tables

Flags

名称 默认 说明
--schema sysbench 内置或者自定义 schema
--host 127.0.0.1 域名或IP
--port 3306 端口
--username root 用户
--password "" 密码
--create-databases false 创建库如果不存在
--create-tables false 创建表如果不存在
--table-size 0 表记录条数,覆盖 Schemasize0 不生效
--timeout 10h 超时时间,3m 表示3分钟结束运行
--db-repeat 0 数据库重复次数,会生成多个库 [dbinsert_1dbinsert_2]

PostgreSQL

PostgreSQL schema

[
  {
    // 数据库名称
    "database": "dbinsert",
    // 表名称
    "table": "tbl",
    // 插入 10000 条数据
    "size": 10000,
    // 主键
    "primaryKeyFieldNames": [
      "id"
    ],
    // 所有列
    "fields": [
      {
        "name": "id",
        "type": "serial"
      },
      {
        "name": "name",
        "type": "CHAR(60)"
      }
    ]
  }
]

内置 Schema

Usage

dbinsert postgres \
  --host 100.100.1.194 \ 
  --port 3306 \
  --user xxx \
  --password xxx \
  --create-databases \
  --create-tables

Flags

名称 默认 说明
--schema sysbench 内置或者自定义 schema
--host 127.0.0.1 域名或IP
--port 5432 端口
--username "" 用户
--password "" 密码
--create-databases false 创建库如果不存在
--create-tables false 创建表如果不存在
--table-size 0 表记录条数,覆盖 Schemasize0 不生效
--timeout 10h 超时时间,3m 表示3分钟结束运行
--db-repeat 0 数据库重复次数,会生成多个库 [dbinsert_1dbinsert_2]

Redis

Usage

dbinsert redis \
  --host 127.0.0.1 \
  --port 6379 \
  --user xxx \
  --password xxx \  
  --key-count 10000 

支持集群:

dbinsert redis \
  --cluster \
  --addrs 127.0.0.1:6379 \
  --user xxx \
  --password xxx  \
  --key-count 30000

Flags

名称 默认 支持类型 说明
--user default 单点和集群 用户
--password "" 单点和集群 密码
--timeout 10h 单点和集群 超时时间,3m 表示3分钟结束运行
--key-count 0 单点和集群 插入的记录数, 0 代表无限
--value-len 50 单点和集群 value 字符串的长度
--host 127.0.0.1 单点 域名或IP
--port 6379 单点 端口
--cluster false 集群 开启集群模式
--addrs 127.0.0.1:6379 集群 逗号分隔的集群地址列表

dbinsert's People

Contributors

vczyh avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.