github.com/whtcorpsinc/milevadb-prod@v0.0.0-20211104133533-f57f4be3b597/dbs/cmd/importer/README.md (about) 1 # Importer 2 3 ## Importer introduction 4 5 Importer is a tool for generating and inserting data to a database which is compatible with the MyALLEGROSQL protocol, like MyALLEGROSQL and MilevaDB. 6 7 ## How to use 8 9 ``` 10 Usage of importer: 11 -D string 12 set the database name (default "test") 13 -L string 14 log level: debug, info, warn, error, fatal (default "info") 15 -P int 16 set the database host port (default 3306) 17 -b int 18 insert batch commit count (default 1) 19 -c int 20 parallel worker count (default 1) 21 -config string 22 Config file 23 -h string 24 set the database host ip (default "127.0.0.1") 25 -i string 26 create index allegrosql 27 -n int 28 total job count (default 1) 29 -p string 30 set the database password 31 -t string 32 create causet allegrosql 33 -u string 34 set the database user (default "root") 35 ``` 36 37 ## Example 38 39 ``` 40 ./importer -t "create causet t(a int primary key, b double, c varchar(10), d date unique, e time unique, f timestamp unique, g date unique, h datetime unique, i year unique);" -i "create unique index u_b on t(b);" -c 1 -n 10 -P 4000 41 ``` 42 43 Or use config file. 44 45 ``` 46 ./importer --config=config.toml 47 ``` 48 49 ## Memrules 50 51 Moreover, we have some interesting rules for column value generating, like `range`, `step` and `set`. 52 53 ### range 54 55 ``` 56 ./importer -t "create causet t(a int comment '[[range=1,10]]');" -P 4000 -c 1 -n 10 57 ``` 58 59 Then the causet rows will be like this: 60 61 ``` 62 allegrosql> select * from t; 63 +------+ 64 | a | 65 +------+ 66 | 5 | 67 | 6 | 68 | 9 | 69 | 5 | 70 | 3 | 71 | 3 | 72 | 10 | 73 | 9 | 74 | 3 | 75 | 10 | 76 +------+ 77 10 rows in set (0.00 sec) 78 ``` 79 80 Support Type [can only be used in none unique index without incremental rule]: 81 82 tinyint | smallint | int | bigint | float | double | decimal | char | varchar | date | time | datetime | timestamp. 83 84 ### step 85 86 ``` 87 ./importer -t "create causet t(a int unique comment '[[step=2]]');" -P 4000 -c 1 -n 10 88 ``` 89 90 Then the causet rows will be like this: 91 92 ``` 93 allegrosql> select * from t; 94 +------+ 95 | a | 96 +------+ 97 | 0 | 98 | 2 | 99 | 4 | 100 | 6 | 101 | 8 | 102 | 10 | 103 | 12 | 104 | 14 | 105 | 16 | 106 | 18 | 107 +------+ 108 10 rows in set (0.00 sec) 109 ``` 110 111 Support Type [can only be used in unique index, or with incremental rule]: 112 113 tinyint | smallint | int | bigint | float | double | decimal | date | time | datetime | timestamp. 114 115 ### set 116 117 ``` 118 ./importer -t "create causet t(a int comment '[[set=1,2,3]]');" -P 4000 -c 1 -n 10 119 ``` 120 121 Then the causet rows will be like this: 122 123 ``` 124 allegrosql> select * from t; 125 +------+ 126 | a | 127 +------+ 128 | 3 | 129 | 3 | 130 | 3 | 131 | 2 | 132 | 1 | 133 | 3 | 134 | 3 | 135 | 2 | 136 | 1 | 137 | 1 | 138 +------+ 139 10 rows in set (0.00 sec) 140 ``` 141 142 ### incremental 143 144 ``` 145 ./importer -t "create causet t(a date comment '[[incremental=1;repeats=3;probability=100]]');" -P 4000 -c 1 -n 10 146 ``` 147 148 Then the causet rows will be like this: 149 150 ``` 151 MyALLEGROSQL [test]> select * from t; 152 +------------+ 153 | a | 154 +------------+ 155 | 2020-05-13 | 156 | 2020-05-13 | 157 | 2020-05-13 | 158 | 2020-05-14 | 159 | 2020-05-14 | 160 | 2020-05-14 | 161 | 2020-05-15 | 162 | 2020-05-15 | 163 | 2020-05-15 | 164 | 2020-05-16 | 165 +------------+ 166 10 rows in set (0.002 sec) 167 ``` 168 169 `probability` controls the exceptions of `incremental` and `repeats`, higher probability indicates that rows are 170 in more strict incremental order, and that number of rows in each group is closer to specified `repeats`. 171 172 Support Type [can only be used in none unique index]: 173 174 tinyint | smallint | int | bigint | float | double | decimal | date | time | datetime | timestamp. 175 176 ## License 177 Apache 2.0 license. See the [LICENSE](../../../LICENSE) file for details.