usage.txt 5.1 KB
Newer Older
aaronchen2k2k's avatar
aaronchen2k2k 已提交
1
ZenData is a generic data generator. You can use YAML file to define the data format and use zendata to create it.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
2

aaronchen2k2k's avatar
aaronchen2k2k 已提交
3
Parameters:
aaronchen2k2k's avatar
aaronchen2k2k 已提交
4 5 6 7

  -d  --default    The default config file for data format.
  -c  --config     The current config file for data format, and it can override the config in the default file.
  -o  --output     The file name of the data generated. You can specify the output format by the extension name.
陈琦 已提交
8
                   For example json, xml, sql, csv and xlsx.  The text data in the original format is output by default.
9
                   Note: For SQL files, you can use --server to specify a specific database type in Mysql\Oracle\SqlServer.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
10 11 12 13
  -n  --lines      The number of lines of data to be generated. The default is 10.

  -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.
14
      --dsn        Specify MySQL\SqlServer\Oracle data source connection string, used to insert data to table directly.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
15
      --clear      Remove data in MySQL table before insert.
陈琦 已提交
16
  -T  --trim       Remove the prefix and postfix of every field when outputting data or decode data to json string.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
17 18
  -H  --human      Output a readable format, print the field name, and use the tab key to split.

aaronchen2k2k's avatar
aaronchen2k2k 已提交
19 20 21
  -r  --recursive  Recursive mode. The default mode is parallel, in which each field loops independently.
                   The value of a field in the recursive mode depends on that of the previous field, which enables the random data.

陈琦 已提交
22
  -p  --port       Run the HTTP on the specified port. The data in JSON format can be obtained via http:\\ip\ port.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
23 24
                   Only data generation is supported.
  -b  --bind       Listen IP addresses. All IP addresses are listened by default.
陈琦 已提交
25
  -R  --root       The root directory when generate data OR running HTTP. The client can call the config file under the root directory.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
26 27
                   If not specified, take the directory where the zd executable file is located.

aaronchen2k2k's avatar
aaronchen2k2k 已提交
28
  -i  --input      Specify a sql schema OR article text file, used to generate YAML config file for it.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
29
                   You need to specify an output directory by using -o.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
30 31
  -D  --decode     Referring to the specified configuration file, parse the data file specified by -i and output json.
                   Also you can output the readable format via -H.
32
  -a  --article    Convert article to yaml config file in the dir provided by -o parameter.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
33

陈琦 已提交
34 35
  -l  --list       List user's data in current dir.
  -L               List build-in data in ZenData install dir.
36
  -v  --view       View detailed definition of a data or resource format.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
37
  -h  --help       Print help.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
38
  -e  --example    Print the data format config file of the example.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
39

aaronchen2k2k's avatar
aaronchen2k2k 已提交
40
Command Line Examples:
aaronchen2k2k's avatar
aaronchen2k2k 已提交
41

42 43 44 45
$>zd.exe -d demo\default.yaml    # Generate 10 lines of data according to the config file specified by -d.
$>zd.exe -c demo\default.yaml    # Generate 10 lines of data according to the config file specified by -c.
$>zd.exe -c demo\default.yaml -r # Generate 10 lines of data according to the config file specified by -c recursively.
$>zd.exe -d demo\default.yaml -c demo\test.yaml -n 100               # Using the parameter of -c and -d at the same time.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
46

47 48 49 50 51
$>zd.exe -d demo\default.yaml -c demo\test.yaml -n 100 -o test.txt   # Output data in original format.
$>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             # 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.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
52
$>zd.exe -c test\test-sql.yaml -t zendata.table_a --trim -dns mysql://root:P2ssw0rd@127.0.0.1:3306/zendata#utf8 --clear # Insert data to MySQL table.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
53

54
$>zd.exe -i demo\zentao.sql -o db                   # Generate YAML files for each table by parsing zentao.sql.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
55
$>zd.exe -i demo\article.txt  -o demo               # Convert article text to yaml config file in demo dir.
56
$>zd.exe -c demo\default.yaml -i test.txt --decode  # Parse the file specified by -i according to the config of -d.
aaronchen2k2k's avatar
1.1  
aaronchen2k2k 已提交
57

aaronchen2k2k's avatar
aaronchen2k2k 已提交
58
$>zd.exe -l                             # List all build-in data types.
59
$>zd.exe -v address.cn.v1               # View data types in build-in Excel file data\address\cn.v1.xlsx.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
60
$>zd.exe -v address.cn.v1.china         # View data items in Excel sheet "china".
61
$>zd.exe -v ip.v1.yaml                  # View data in build-in instances defined in yaml\ip\v1.yaml。
aaronchen2k2k's avatar
aaronchen2k2k 已提交
62

aaronchen2k2k's avatar
aaronchen2k2k 已提交
63
Service Example:
aaronchen2k2k's avatar
aaronchen2k2k 已提交
64

aaronchen2k2k's avatar
aaronchen2k2k 已提交
65 66
$zd.exe -p 80                           # Listen port 80. Use the directory of zd.exe as the root.
$zd.exe -p 80 -R d:\zd\config           # Listen port 80. Use d:\zd\config as the root.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
67

aaronchen2k2k's avatar
aaronchen2k2k 已提交
68
Client Call:
aaronchen2k2k's avatar
aaronchen2k2k 已提交
69

陈琦 已提交
70
$curl http:\\localhost:8848\?d=demo\default.yaml&c=demo\config.yaml&n=100&T=true   # Specify the server config file via GET.
71 72
$curl http:\\localhost:8848\?default=demo\default.yaml&output=test.sql&table=user  # Parameter names can be full.
$curl -i -X POST http:\\localhost:8848?lines=3 -F default=@demo\default.yaml       # The config can be uploaded via POST.