提交 738db9bf 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

Merge remote-tracking branch 'origin/master'

......@@ -12,6 +12,7 @@ zendata是一款通用的数据生成工具,您可以使用yaml文件来定义
-F --field 可通过该参数指定要输出的字段列表,用逗号分隔。 默认是所有的字段。
-t --table 输出格式为sql时,需通过该参数指定要插入数据的表名。
-T --trim 输出数据时去掉前缀和后缀,可用于输出json、xml或者sql格式时。
-H --human 输出可读格式,打印字段名,并使用tab键进行分割。
-b --bind 监听的ip地址,默认监听所有的ip地址。
......@@ -38,6 +39,7 @@ $>zd.exe -d demo\default.yaml -c demo\test.yaml -n 100 -o test.txt 输出原
$>zd.exe -d demo\default.yaml -c demo\test.yaml -n 100 -o test.json 输出json格式的数据。
$>zd.exe -d demo\default.yaml -c demo\test.yaml -n 100 -o test.xml 输出xml格式的数据。
$>zd.exe -d demo\default.yaml -n 100 -o test.sql -t user -s mysql 输出插入到user表里面的sql。
$>zd.exe -d demo\default.yaml -o test.sql -t user -s mysql --trim 输出时去除字段的前缀和后缀。
$>zd.exe -i db.sql -s mysql -o db 根据db.sql的定义生成每个表的yaml文件,存储到db目录里面。
$>zd.exe -c demo\default.yaml -i test.txt --decode 将-i指定的文件根据-d参数的配置进行解析。
......
......@@ -49,10 +49,11 @@ desc:
# 元素也可以是一个区间。比如 range:1-10, A-Z
# 区间可以通过冒号:来指定步长。比如 range:1-10:2。
# 步长可以是小数。比如 range: 1-10:0.1
# 步长可以是负数。比如 range: 9-1:-1
# 区间可以通过R来指定随机。比如 range: 1-10:R,随机和步长只能二选一。
# 可以通过一个文件来指定列表。比如range: list.txt。文件名是相对路径时,以配置文件为基准计算。
# 可以通过{n}的方式来重复某一个元素。比如 range: user1{100},user2{100}
# 如果区间或者几个元素需要重复,需要用[]括起来。比如 range: [user1,user2,user3]{100}
# 如果区间或者几个元素需要重复,需要用[]括起来。比如 range: [user1,user2,user3]{100}, [1-100]{10}
author: zentao
version: 1.0
......@@ -64,8 +65,8 @@ fields:
prefix: int_ # 前缀
postfix: "\t" # 后缀,特殊字符加引号,否则无法解析。
- field: field_step # 区间可以指定步长。
range: 1-10:2, 1-2:0.1 # 1,3,5,7,9,1, 1.1,1.2...,2
- field: field_step # 区间可以指定步长,步长可以为小数或者负数
range: 1-10:2, 1-2:0.1,9-1:-1 # 1,3,5,7,9,1, 1.1,1.2...,2,9,8,7,1
postfix: "\t"
- field: field_random # 通过R属性指定随机。R属性和步长不能同时出现。
......@@ -83,13 +84,18 @@ fields:
postfix: "\t"
- field: field_repeat # 通过{}定义重复的元素。
range: user-1{3},[user2,user3]{2} # user-1,user-1,user-1,user2,user3,user2,user3
range: u-1{3},[u2,u3]{2},[1-3]{3} # u-1,u1,u1,u2,u2,u3,u3,1,1,1,2,2,2,3,3,3
postfix: "\t"
- field: field_format # 通过格式化字符串输出。
range: 1-10 # passwd 1,passwd 2,passwd 3 ... passwd10。
format: "passwd%02d" # 用%2d补零,使密码整体保持8位,%2d默认补空格。
postfix: "\t"
- field: field_length # 固定长度的字段。
range: 1-100 # 001,002,003..., 099,100
length: 3 # 三个字节。
leftpad: 0 # 使用0左填充。
- field: field_use_another_file # 可以引用其他的定义文件。
config: numb_field.yaml # 引用当前目录下面的numb_field.yaml文件里面的定义。
......@@ -102,7 +108,7 @@ fields:
- field: field_use_instance # 引用其他的定义文件,该文件定义了多个实例。
from: system.ip.v1.yaml # 引用data/system/ip/v1.yaml
use: privateC,privateC # 使用该文件中定义的privateC和privateB两个实例。
use: privateC,privateB # 使用该文件中定义的privateC和privateB两个实例。
postfix: "\t"
- field: field_use_excel # 从excel数据源里面取数据。
......
......@@ -49,10 +49,11 @@ desc:
# Elements can be a range, e.g. range:1-10, A-Z.
# Use colons to define steps, e.g. range:1-10:2.
# Steps can be decimals, e.g. range: 1-10:0.1.
# Steps can be negative, e.g. range: 9-1:-1
# Intervals can be set as random by R, e.g. range: 1-10:R. Set either random or a specified step.
# Use a file to specify a list, e.g. range: list.txt. If the file name is a relative path, it is based on the config file.
# Use {n} to repeat a element, e.g. range: user1{100},user2{100}.
# Use [], if intervals and elements are repeated, e.g. range: [user1,user2,user3]{100}.
# Use [], if intervals and elements are repeated, e.g. range: [user1,user2,user3]{100}, [1-100]{10}.
author: zentao
version: 1.0
......@@ -64,16 +65,16 @@ fields:
prefix: int_ # Prefix
postfix: "\t" # Postfix
- field: field_step # Interval steps can be specified.
range: 1-10:2, 1-2:0.1 # 1,3,5,7,9,1, 1.1,1.2...,2
- field: field_step # Interval steps can be specified.
range: 1-10:2, 1-2:0.1,9-1:-1 # 1,3,5,7,9,1, 1.1,1.2...,2,9,8,7,...,1
postfix: "\t"
- field: field_random # Use R to specify randomly. Set either R or a specified step.
range: 1-10:R # 1,5,8...
- field: field_random # Use R to specify randomly. Set either R or a specified step.
range: 1-10:R # 1,5,8...
postfix: "\t"
- field: field_file # Read a list from a file and set it as random.
range: users.txt:R # Using the lines of users.txt as range and set it as random.
- field: field_file # Read a list from a file and set it as random.
range: users.txt:R # Using the lines of users.txt as range and set it as random.
postfix: "\t"
- field: field_loop # Self-loop field.
......@@ -83,14 +84,19 @@ fields:
postfix: "\t"
- field: field_repeat # Use {} to define repeated elements.
range: user-1{3},[user2,user3]{2} # user-1,user-1,user-1,user2,user3,user2,user3
range: u-1{3},[u2,u3]{2},[1-3]{3} # u-1,u-1,u-1,u2,u2,user3,user3,1,1,1,2,2,2,3,3,3
postfix: "\t"
- field: field_format # Output as formatted strings.
range: 1-10 # passwd 1,passwd 2,passwd 3 ... passwd10。
format: "passwd%02d"
postfix: "\t"
- field: field_length # Fixed length field.
range: 1-100 # 001,002,003..., 099,100
length: 3 # the length in Byte.
leftpad: 0 # Using 0 to pad.
- field: field_use_another_file # Other definition file can be referred.
config: number_field.yaml # Refer to the definition in number_field.yaml of the current directory.
postfix: "\t"
......
$zd
$zd
zendata is a generic data generator. You can use YAML file to define the data format and use zendata to create it.
......@@ -12,6 +12,7 @@ Parameters
-F --field This parameter can be used to specify the fields, separated by commas. The default is all fields.
-t --table If the output format is sql, using it to specify the table name to insert data to.
-T --trim Remove the prefix and postfix of every field when outputting data.
-H --human Output a readable format, print the field name, and use the tab key to split.
-r --recursive Recursive mode. The default mode is parallel, in which each field loops independently.
......@@ -43,6 +44,7 @@ $>zd.exe -d demo/default.yaml -c demo/test.yaml -n 100 -o test.txt # Output da
$>zd.exe -d demo/default.yaml -c demo/test.yaml -n 100 -o test.json # Output data in JSON.
$>zd.exe -d demo/default.yaml -c demo/test.yaml -n 100 -o test.xml # Output data in XML.
$>zd.exe -d demo/default.yaml -n 100 -o test.sql -t user -s mysql # Output the sql inserted into the table user.
$>zd.exe -d demo/default.yaml -o test.sql -t user -s mysql --trim # Remove the prefix and postfix of every field.
$>zd.exe -i db.sql -o db # Generate YAML files for each table by parsing db.sql and store them in the db directory.
$>zd.exe -c demo/default.yaml -i test.txt --decode # Parse the file specified by -i according to the config of -d.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册