usage.txt 4.0 KB
Newer Older
aaronchen2k2k's avatar
aaronchen2k2k 已提交
1 2 3 4 5 6 7 8 9 10 11 12
zendata is a generic data generator. You can use YAML file to define the data format and use zendata to create it.

Parameters

  -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.
                   For example json, xml and sql.  The text data in the original format is output by default.
  -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.
13
  -T  --trim       Remove the prefix and postfix of every field when outputting data.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
14 15
  -H  --human      Output a readable format, print the field name, and use the tab key to split.

aaronchen2k2k's avatar
aaronchen2k2k 已提交
16 17 18
  -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.

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

  -i  --input      Specify a sql schema file and output the YAML config file for each table. 
                   You need to specify an output directory by using -o.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
27 28
  -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.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
29 30 31 32

  -l  --list       List all supported data formats.
  -v  --view       View the detailed definition of a data format.
  -h  --help       Print help.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
33
  -e  --example    Print the data format config file of the example.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
34 35 36 37 38 39 40 41 42 43 44

Command Line Examples

$>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 -d demo/default.yaml -c demo/test.yaml -n 100  # Using the parameter of -c and -d at the same time.

$>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 -s mysql    # Output the sql inserted into the table user.
45
$>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 已提交
46

aaronchen2k2k's avatar
1.1  
aaronchen2k2k 已提交
47
$>zd.exe -i db.sql -o db  # Generate YAML files for each table by parsing db.sql and store them in the db directory.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
48
$>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 已提交
49 50 51 52

$>zd.exe -l                         # List all build-in data types.
$>zd.exe -v system.address.v1       # View data types in build-in Excel file system/address/v1.xlsx.
$>zd.exe -v system.address.v1.china # View data items in Excel sheet "china".
aaronchen2k2k's avatar
aaronchen2k2k 已提交
53 54 55

Service Example

aaronchen2k2k's avatar
1.1  
aaronchen2k2k 已提交
56
$zd.exe -p 80 -R d:\zd\config  # Listen port 80. Use d:\zd\config as the root.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
57 58 59 60 61 62

Client Call

$curl http://loclahost/?d=default.yaml&c=config.yaml&n=100&o=test.sql&t=user  # Specify the server config file via GET.
$curl http://loclahost/?default=default.yamloutput=test.sql&table=user        # Parameter names can be full.
$curl -d "default=...&config=...&lines=10" http://localhost/                  # The config can be uploaded via POST.