You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#### ✅ Step 1.3.b. Open a `new` shell to finalize install
53
+
```
54
+
[What's NEXT ?]
55
+
You are all set. You can now:
56
+
• Use any command, 'astra help' will get you the list
57
+
• Try with 'astra db list'
58
+
• Enter interactive mode using 'astra'
59
+
60
+
Happy Coding !
61
+
```
62
+
63
+
#### ✅ Step 1.3.c - Open a `NEW` shell to finalize install
64
+
65
+
- Get the current version
54
66
55
67
```
56
68
astra --version
69
+
```
70
+
71
+
- Get some more informations
72
+
73
+
```
57
74
astra help
58
75
```
59
76
77
+
- Use you configuration (spoiler)
78
+
79
+
```
80
+
astra user list
81
+
```
82
+
60
83
## 2. Configuration Management
61
84
62
-
-**List Configurations**
85
+
#### ✅ Step 2.1 - List Configuration
86
+
87
+
- In your configuration file you see all config and one is the default. This is the one used when no option provided.
63
88
64
89
```
65
90
astra config list
66
91
```
67
92
68
-
-**Create new configuration**
93
+
#### ✅ Step 2.2 - Create new configuration
94
+
95
+
If you have multiple organizations it could be useful to switch from one to another.
69
96
70
-
If you have multiple organizations it could be useful to switch from one to another. To create another config, the latest created org will become the default.
97
+
- Create anotherorg called `dev`
71
98
72
99
```
73
100
astra config create dev -t <token_of_org_2>
74
101
```
75
102
103
+
- Look at the new list with `dev`
104
+
76
105
```
77
106
astra config list
78
107
```
79
108
80
-
When you issue any command the config is now loaded for you:
109
+
- But nothing change your are still on default
81
110
82
111
```
83
112
astra user list
84
113
```
85
114
86
-
-**Change default configuration**:
115
+
#### ✅ Step 2.3 - Change default configuration
87
116
88
117
You can change the default org at any time with the following command:
You can delete any organization. I see you.. if you delete the default one you are on your own and you would need to define a new one.
115
151
152
+
- Delete you config
116
153
```
117
154
astra config delete dev
155
+
```
156
+
157
+
- See the new list
158
+
159
+
```
118
160
astra config list
119
161
```
120
162
121
163
## 3. Working with Databases
122
164
123
-
-**List Databases**:
165
+
#### ✅ Step 3.1 List Databases
124
166
125
167
```
126
168
astra db list
127
169
```
128
170
129
-
-**Create a new database:**
171
+
#### ✅ Step 3.2 Create a new database
130
172
131
173
If not provided the region will be the default free region and the keyspace will be the database name but you can change then with `-r` and `-k` respectivitely.
132
174
175
+
- Create the Database
176
+
133
177
```
134
178
astra db create demo
135
-
astra db list
136
179
```
137
180
138
-
-**Get information on your database**
181
+
-Check the status
139
182
140
-
Notice how you never provide any the technical ids.
183
+
```
184
+
astra db list
185
+
```
186
+
187
+
#### ✅ Step 3.3 Get information on your database
141
188
142
189
```
143
190
astra db get demo
144
191
```
145
192
146
-
-**Change output format**
193
+
> **Note:** You never provided any the technical ids.
194
+
195
+
196
+
#### ✅ Step 3.4 Output Format
147
197
148
198
This CLI wil be used by CI/CD and script, sometimes the output must be parsed. There are 3 outputs: *human,json,csv"
149
199
200
+
- Show the list as a json
201
+
150
202
```
151
203
astra db list -o json
152
204
```
153
205
206
+
- Show the list as a csv
207
+
154
208
```
155
209
astra db list -o csv
156
210
```
157
211
212
+
#### ✅ Step 3.5 Error Code
213
+
158
214
The return type is also important to check the errors. O mean everything is OK
159
215
216
+
- Execute command with error
160
217
```
161
-
echo $?
218
+
astra db get i_do_not_exist -v
162
219
```
163
220
221
+
- Get the error code
164
222
```
165
-
astra db get i_do_not_exist && echo $?
223
+
echo $?
166
224
```
167
225
168
-
Error codes tables
226
+
-Error codes table:
169
227
170
228
| Error | Code |
171
229
|-------------------|-----------|
@@ -179,10 +237,14 @@ Error codes tables
179
237
| INTERNAL_ERROR | 40 |
180
238
181
239
182
-
- The cli implemented `If not Exist` for both keyspace and database (convenient for workshops and training)
240
+
#### ✅ Step 3.6 - If not Exists
241
+
242
+
The cli implemented `If not Exist` for both keyspace and database (convenient for workshops and training)
243
+
244
+
245
+
- Run the command with `--if-not-exist`
183
246
184
247
```
185
-
astra help db create
186
248
astra db create demo --if-not-exist
187
249
```
188
250
@@ -194,21 +256,27 @@ astra db create demo --if-not-exist -v
194
256
195
257
Make sure the database is now Active or you will get some expected errors.
196
258
197
-
-**Create a new keyspace**
259
+
```
260
+
astra db get demo | grep ACTIVE
261
+
```
198
262
263
+
#### ✅ Step 3.7 - Create Keyspace
199
264
```
200
265
astra db create-keyspace demo -k ks2
201
266
```
202
267
203
-
Need helps ?
268
+
- Keyspace is created
269
+
204
270
```
205
-
astra help db create-keyspace
271
+
astra db get demo
206
272
```
207
273
208
-
- Now let's blow your mind 🥁
274
+
#### ✅ Step 3.8 - Blow your mind 🥁
275
+
276
+
The first execution is expected to be slow we are downloading cqlsh if not present on your machine. This is why we put the `-v`.
209
277
210
278
```
211
-
astra db cqlsh demo
279
+
astra db cqlsh demo -v
212
280
```
213
281
214
282
- Quit the shell
@@ -217,16 +285,18 @@ astra db cqlsh demo
217
285
quit;
218
286
```
219
287
220
-
- Execute CQL (or CQL file)
288
+
- Execute a CQL statement (or a CQL file with `-f`)
221
289
222
290
```
223
291
astra db cqlsh demo -e "describe keyspaces;"
224
292
```
225
293
226
-
###D. Interactive mode
294
+
#### ✅ Step 3.9 - Interactive Shell
227
295
228
296
Commands we used so far are stateless, no connection is maintained after the execution. What if you need more an interactive shell than a cli ?
229
297
298
+
- Start the shell by do not providing any command
299
+
230
300
```
231
301
astra
232
302
```
@@ -243,12 +313,14 @@ db list
243
313
db get demo
244
314
```
245
315
246
-
Now what if we want some commands on this particular db ?
316
+
-Now what if we want some commands on this particular db ?
247
317
248
318
```
249
319
db use demo
250
320
```
251
321
322
+
- Get info of a
323
+
252
324
```
253
325
info
254
326
```
@@ -267,42 +339,49 @@ create keyspace kso
267
339
cqlsh -k kso
268
340
```
269
341
270
-
Now quit:
342
+
- No Quit:
271
343
272
344
```
273
345
quit;
274
346
```
275
347
276
348
## 4. Working with Users
277
349
278
-
- List your users
350
+
#### ✅ Step 4.1 - List your users
279
351
280
352
```
281
353
astra user list
282
354
```
283
355
284
-
- Invite your best friend (me). The role will be DataStax Administrator by default
356
+
#### ✅ Step 4.2 - Invite your best friend (me).
357
+
358
+
- The role will be `DataStax Administrator` by default
0 commit comments