Skip to content

Commit d1f4830

Browse files
committed
New translations cql_db_manage.md (Chinese Simplified)
1 parent 9bb99ce commit d1f4830

File tree

1 file changed

+102
-73
lines changed

1 file changed

+102
-73
lines changed

website/translated_docs/zh-CN/cql_db_manage.md

Lines changed: 102 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,36 @@ title: Database Management
55

66
## Creating Database
77

8-
Like `transfer`, `create` takes a `json` format main parameter. Create a database with one miner node with:
8+
Like `transfer`, `create` takes several parameters. e.g. Create a database with one miner node:
99

1010
```bash
11-
cql create '{"node": 1}'
11+
cql create -db-node 1
1212
```
1313

1414
Output:
1515

16-
Enter master key(press Enter for default: ""):
16+
INFO[0000] Geting bp address from dns: bp00.testnet.gridb.io
17+
INFO[0048] Register self to blockproducer: 00000000000589366268c274fdc11ec8bdb17e668d2f619555a2e9c1a29c91d8
18+
INFO init config success path=~/.cql/config.yaml
19+
INFO create database requested
1720

18-
covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872
21+
The newly created database is: "covenantsql://962bbb3a8028a203e99121d23173a38fa24a670d52c8775a9d987d007a767ce4"
22+
The connecting string beginning with 'covenantsql://' could be used as a dsn for `cql console`
23+
or any command, or be used in website like https://web.covenantsql.io
1924

2025

21-
Here `covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` is the database source name (DSN) of the created database. And the `covenantsql` part is the scheme, which can be `cql` in abbreviation. The hex string after `://` is the database address, which can be used as a receiver address in `transfer` command.
26+
Here `covenantsql://962bbb3a8028a203e99121d23173a38fa24a670d52c8775a9d987d007a767ce4` is the database source name (DSN) of the created database. And the `covenantsql` part is the scheme, which can be `cql` in abbreviation. The hex string after `://` is the database address, which can be used as a receiver address in `transfer` command.
2227

2328
The sub-command `create` sends transactions to block producers to create databases, so it has a `wait-tx-confirm` parameter too.
2429

2530
For a complete help message, check [Complete Parameters](#sub-command-create-complete-parameters).
2631

2732
## Billing
2833

29-
CovenantSQL uses Gas for billing just like the [Ethereum Gas](https://www.ethos.io/what-is-ethereum-gas/). The gas unit (a.k.a., the `Gas-Price`) in stable token `Particle` is specified while creating the database, and its corresponding field is `gas-price`. If not specified in the json string, it will be set as 1 by default. Another billing-related field is `advance-payment`, which will be used as deposit and query expending. The default advance payment is 20,000,000. Creating a database with specified `Gas-Price` and `Advance-Payment`:
34+
CovenantSQL uses Gas for billing just like the [Ethereum Gas](https://www.ethos.io/what-is-ethereum-gas/). The gas unit (a.k.a., the `Gas-Price`) in stable token `Particle` is specified while creating the database, and its corresponding field is `-db-gas-price`. If not specified in the parameter, it will be set as 1 by default. Another billing-related field is `-db-advance-payment`, which will be used as deposit and query expending. The default advance payment is 20,000,000. Creating a database with specified `Gas-Price` and `Advance-Payment`:
3035

3136
```bash
32-
cql create '{"node": 2, "gas-price": 5, "advance-payment": 500000000}'
37+
cql create -db-node 2 -db-gas-price 5 -db-advance-payment 500000000
3338
```
3439

3540
Thus we created a new database with `Gas-Price` 5 and `Advance-Payment` 500,000,000. Note that when the CovenantSQL network is short of miner resources, setting a higher `Gas-Price` will help your creation request to be accepted earlier, but it will cost you more tokens of course.
@@ -59,36 +64,44 @@ CovenantSQL database has 3 kinds of access permission:
5964

6065
Among them, `Admin` is the permission that can assign permissions (`Admin`, `Write`, or `Read`) to the other accounts. `Admin` and `Write` allows the write queries (such as `CREATE`, `INSERT`, and etc.). `Admin` and `Read` allows the read queries (such as `SHOW`, `SELECT`, and etc.). If you want to allow a user to read/write the database but not allow to modify the permissions of itself or other accounts, you can assign the user permission as `Read,Write`. `Void` is a special kind of permission which means 'no permission'. Once the `Admin` sets the permission of an account as `Void`, it will no longer able to read or write the database. The account who creates the database will be granted the initial `Admin` permission by default.
6166

62-
Assume that you have created a database `covenantsql:\\4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5` with default account, and have generated another account under directory `account2` which has the address `011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6`. Now you can grant permissions to `accounts` to access the database, with the `json` format main parameter as following:
67+
Assume that you have created a database `covenantsql:\\4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5` with default account, and have generated another account under directory `account2` which has the address `011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6`. Now you can grant permissions to `accounts` to access the database, with parameters as following:
6368

64-
```json
65-
{
66-
"chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", // Target database adderss to give permission
67-
"user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // Target wallet address to get permission
68-
"perm": "Read,Write" // Permission, separated by commas
69-
}
69+
```bash
70+
`-to-dsn` Target database adderss to give permission
71+
`-to-user` Target wallet address to get permission
72+
`-perm` Permission, separated by commas
7073
```
7174

7275
Pass the parameter to `grant`:
7376

7477
```bash
75-
cql grant '{"chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", "perm": "Read,Write"}'
78+
cql grant -to-dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 \
79+
-to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 \
80+
-perm "Read,Write"
7681
```
7782

7883
Output:
7984

80-
INFO[0000] succeed in sending transaction to CovenantSQL
85+
INFO[0000] Geting bp address from dns: bp04.testnet.gridb.io
86+
INFO[0003] Self register to blockproducer: 00000000003b2bd120a7d07f248b181fc794ba8b278f07f9a780e61eb77f6abb
87+
INFO init config success path=~/.cql/config.yaml
88+
INFO succeed in grant permission on target database
8189

8290

8391
Or revoke the permission:
8492

8593
```bash
86-
cql grant '{"chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", "perm": "Void"}'
94+
cql grant -to-dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 \
95+
-to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 \
96+
-perm "Void"
8797
```
8898

8999
Output:
90100

91-
INFO[0000] succeed in sending transaction to CovenantSQL
101+
INFO[0000] Geting bp address from dns: bp04.testnet.gridb.io
102+
INFO[0003] Self register to blockproducer: 00000000003b2bd120a7d07f248b181fc794ba8b278f07f9a780e61eb77f6abb
103+
INFO init config success path=~/.cql/config.yaml
104+
INFO succeed in grant permission on target database
92105

93106

94107
The sub-command `grant` sends transactions to block producers to request permission granting, so it has a `wait-tx-confirm` parameter too.
@@ -98,7 +111,10 @@ Since the database separately keeps billing for each user, you need to transfer
98111
Transferring from `account2` to the database:
99112

100113
```bash
101-
cql -config "account2/config.yaml" transfer '{"addr": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","amount": "90000000 Particle"}'
114+
cql transfer -config "account2/config.yaml" \
115+
-to-dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 \
116+
-amount 90000000 \
117+
-token Particle
102118
```
103119

104120
### SQL White List
@@ -108,17 +124,15 @@ CovenantSQL supports white list setting for each of its users. By setting up SQL
108124
Adding a white list:
109125

110126
```bash
111-
cql grant '
127+
cql grant -to-dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 \
128+
-to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 \
129+
-perm '
112130
{
113-
"chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5",
114-
"user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6",
115-
"perm": {
116-
"patterns": [
117-
"SELECT COUNT(1) FROM a",
118-
"SELECT * FROM a WHERE id = ? LIMIT 1"
119-
],
120-
"role": "Read,Write"
121-
}
131+
"patterns": [
132+
"SELECT COUNT(1) FROM a",
133+
"SELECT * FROM a WHERE id = ? LIMIT 1"
134+
],
135+
"role": "Read,Write"
122136
}
123137
'
124138
```
@@ -128,87 +142,102 @@ cql grant '
128142
Cleaning the white list:
129143

130144
```bash
131-
cql grant '
145+
<br />cql grant -to-dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 \
146+
-to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 \
147+
-perm '
132148
{
133-
"chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5",
134-
"user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6",
135-
"perm": {
136-
"patterns": nil,
137-
"role": "Read,Write"
138-
}
149+
"patterns": nil,
150+
"role": "Read,Write"
139151
}
140152
'
153+
141154
or
142-
cql grant '
143-
{
144-
"chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5",
145-
"user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6",
146-
"perm": "Read,Write"
147-
}
148-
'
155+
156+
cql grant -to-dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 \
157+
-to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 \
158+
-perm "Read,Write"
149159
```
150160

151161
Either setting the `pattern` field to `nil` or just resetting the user permission directly, will eliminate the white list and give back the access permission to the user.
152162

153163
## Sub-command `create` Complete Parameters
154164

155-
usage: cql create [common params] [-wait-tx-confirm] db_meta_json
165+
usage: cql create [common params] [-wait-tx-confirm] [db_meta_params]
156166

157-
Create creates a CovenantSQL database by database meta info JSON string. The meta info must include node count.
167+
Create command creates a CovenantSQL database by database meta params. The meta info must include
168+
node count.
158169
e.g.
159-
cql create '{"node": 2}'
160-
161-
A complete introduction of db_meta_json fields:
162-
target-miners []string // List of target miner addresses
163-
node int // Target node number
164-
space int // Minimum disk space requirement, 0 for none
165-
memory int // Minimum memory requirement, 0 for none
166-
load-avg-per-cpu float // Minimum idle CPU requirement, 0 for none
167-
encrypt-key string // Encryption key for persistence data
168-
eventual-consistency bool // Use eventual consistency to sync among miner nodes
169-
consistency-level float // Consistency level, node*consistency_level is the node number to perform strong consistency
170-
isolation-level int // Isolation level in a single node
171-
gas-price int // Specified Gas Price of the database, default is 1 Particle
172-
advance-payment int // Specified advance payment of the database, default is 20,000,000 Particles
170+
cql create -db-node 2
173171

174-
Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction confirmation before the creation takes effect.
172+
Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction
173+
confirmation before the creation takes effect.
175174
e.g.
176-
cql create -wait-tx-confirm '{"node": 2}'
177-
178-
Params:
175+
cql create -wait-tx-confirm -db-node 2
176+
177+
DB meta params:
178+
-db-advance-payment uint
179+
Customized advance payment
180+
-db-consistency-level float
181+
Consistency level, node*consistency_level is the node count to perform strong consistency
182+
-db-encrypt-key string
183+
Encryption key for persistence data
184+
-db-eventual-consistency
185+
Use eventual consistency to sync among miner nodes
186+
-db-gas-price uint
187+
Customized gas price
188+
-db-isolation-level int
189+
Isolation level in a single node
190+
-db-load-avg-per-cpu float
191+
Minimum idle CPU requirement, 0 for none
192+
-db-memory uint
193+
Minimum memory requirement, 0 for none
194+
-db-node uint
195+
Target node count
196+
-db-space uint
197+
Minimum disk space requirement, 0 for none
198+
-db-target-miners value
199+
List of target miner addresses(separated by ',')
179200
-wait-tx-confirm
180201
Wait for transaction confirmation
181202

182203

183204
## Sub-command `drop` Complete Parameters
184205

185-
usage: cql drop [common params] [-wait-tx-confirm] dsn/dbid
206+
usage: cql drop [common params] [-wait-tx-confirm] dsn
186207

187208
Drop drops a CovenantSQL database by DSN or database ID.
188209
e.g.
189210
cql drop covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c
190211

191-
Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction confirmation before the drop operation takes effect.
212+
Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction
213+
confirmation before the drop operation takes effect.
192214
e.g.
193215
cql drop -wait-tx-confirm covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c
194216

195-
Params:
217+
Drop params:
196218
-wait-tx-confirm
197219
Wait for transaction confirmation
198220

199221

200222
## Sub-command `grant` Complete Parameters
201223

202-
usage: cql grant [common params] [-wait-tx-confirm] permission_meta_json
224+
usage: cql grant [common params] [-wait-tx-confirm] [-to-user wallet] [-to-dsn dsn] [-perm perm_struct]
203225

204-
Grant grants specific permissions for the target user.
226+
Grant grants specific permissions for the target user on target dsn.
205227
e.g.
206-
cql grant '{"chain": "your_chain_addr", "user": "user_addr", "perm": "perm_struct"}'
228+
cql grant -to-user=43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -to-dsn="covenantsql://xxxx" -perm perm_struct
207229

208-
Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction confirmation before the permission takes effect.
230+
Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction
231+
confirmation before the permission takes effect.
209232
e.g.
210-
cql grant -wait-tx-confirm '{"chain":"your_chain_addr","user":"user_addr","perm":"perm_struct"}'
211-
212-
Params:
233+
cql grant -wait-tx-confirm -to-user=43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -to-dsn="covenantsql://xxxx" -perm perm_struct
234+
235+
Grant params:
236+
-perm string
237+
Permission type struct for grant.
238+
-to-dsn string
239+
Target database dsn to grant permission.
240+
-to-user string
241+
Target address of an user account to grant permission.
213242
-wait-tx-confirm
214243
Wait for transaction confirmation

0 commit comments

Comments
 (0)