Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
zendata
提交
738db9bf
Z
zendata
项目概览
LinuxSuRen
/
zendata
与 Fork 源项目一致
Fork自
易企天创 / zendata
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zendata
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
738db9bf
编写于
7月 23, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/master'
上级
f26f605b
58907e0b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
15 deletion
+31
-15
README.md
README.md
+2
-0
demo/default.yaml
demo/default.yaml
+11
-5
res/doc/sample_en.yaml
res/doc/sample_en.yaml
+15
-9
res/doc/usage_en.txt
res/doc/usage_en.txt
+3
-1
未找到文件。
README.md
浏览文件 @
738db9bf
...
...
@@ -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
\d
efault.yaml
-c
demo
\t
est.yaml
-n
100
-o
test.json 输出json格式的数据。
$>
zd.exe
-d
demo
\d
efault.yaml
-c
demo
\t
est.yaml
-n
100
-o
test.xml 输出xml格式的数据。
$>
zd.exe
-d
demo
\d
efault.yaml
-n
100
-o
test.sql
-t
user
-s
mysql 输出插入到user表里面的sql。
$>
zd.exe
-d
demo
\d
efault.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
\d
efault.yaml
-i
test.txt
--decode
将-i指定的文件根据-d参数的配置进行解析。
...
...
demo/default.yaml
浏览文件 @
738db9bf
...
...
@@ -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
:
u
ser-1{3},[user2,user3]{2}
# user-1,user-1,user-1,user2,user3,user2,user
3
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,private
C
# 使用该文件中定义的privateC和privateB两个实例。
use
:
privateC,private
B
# 使用该文件中定义的privateC和privateB两个实例。
postfix
:
"
\t
"
-
field
:
field_use_excel
# 从excel数据源里面取数据。
...
...
res/doc/sample_en.yaml
浏览文件 @
738db9bf
...
...
@@ -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
:
u
ser-1{3},[user2,user3]{2}
# user-1,user-1,user-1,user2,user3,user2,user
3
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
"
...
...
res/doc/usage_en.txt
浏览文件 @
738db9bf
$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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录