forked from yugabyte/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
various fixes incl. addition of ycql quick start to ycql api section
- Loading branch information
Sid Choudhury
committed
Mar 15, 2019
1 parent
d01a7fc
commit e9d616c
Showing
44 changed files
with
294 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
--- | ||
title: Quick Start YCQL | ||
linkTitle: Quick Start YCQL | ||
description: Quick Start | ||
image: /images/section_icons/quick_start/explore_ycql.png | ||
aliases: | ||
- /quick-start/test-cassandra/ | ||
- /latest/quick-start/test-cassandra/ | ||
- /latest/quick-start/test-ycql/ | ||
menu: | ||
latest: | ||
parent: api-cassandra | ||
weight: 1100 | ||
--- | ||
|
||
After [creating a local cluster](../../../quick-start/create-local-cluster/), follow the instructions below to explore the [YCQL](../) API. | ||
|
||
[**cqlsh**](http://cassandra.apache.org/doc/latest/tools/cqlsh.html) is a command line shell for interacting with [CQL (the Cassandra Query Language)](http://cassandra.apache.org/doc/latest/cql/index.html) servers. It uses the Python driver, and connects to the single node specified on the command line. For ease of use, YugaByte DB ships with the 3.10 version of cqlsh in its bin directory. | ||
|
||
## 1. Connect with cqlsh | ||
|
||
<ul class="nav nav-tabs nav-tabs-yb"> | ||
<li > | ||
<a href="#macos" class="nav-link active" id="macos-tab" data-toggle="tab" role="tab" aria-controls="macos" aria-selected="true"> | ||
<i class="fab fa-apple" aria-hidden="true"></i> | ||
macOS | ||
</a> | ||
</li> | ||
<li> | ||
<a href="#linux" class="nav-link" id="linux-tab" data-toggle="tab" role="tab" aria-controls="linux" aria-selected="false"> | ||
<i class="fab fa-linux" aria-hidden="true"></i> | ||
Linux | ||
</a> | ||
</li> | ||
<li> | ||
<a href="#docker" class="nav-link" id="docker-tab" data-toggle="tab" role="tab" aria-controls="docker" aria-selected="false"> | ||
<i class="fab fa-docker" aria-hidden="true"></i> | ||
Docker | ||
</a> | ||
</li> | ||
<li > | ||
<a href="#kubernetes" class="nav-link" id="kubernetes-tab" data-toggle="tab" role="tab" aria-controls="kubernetes" aria-selected="false"> | ||
<i class="fas fa-cubes" aria-hidden="true"></i> | ||
Kubernetes | ||
</a> | ||
</li> | ||
</ul> | ||
|
||
<div class="tab-content"> | ||
<div id="macos" class="tab-pane fade show active" role="tabpanel" aria-labelledby="macos-tab"> | ||
{{% includeMarkdown "binary/explore-ycql.md" /%}} | ||
</div> | ||
<div id="linux" class="tab-pane fade" role="tabpanel" aria-labelledby="linux-tab"> | ||
{{% includeMarkdown "binary/explore-ycql.md" /%}} | ||
</div> | ||
<div id="docker" class="tab-pane fade" role="tabpanel" aria-labelledby="docker-tab"> | ||
{{% includeMarkdown "docker/explore-ycql.md" /%}} | ||
</div> | ||
<div id="kubernetes" class="tab-pane fade" role="tabpanel" aria-labelledby="kubernetes-tab"> | ||
{{% includeMarkdown "kubernetes/explore-ycql.md" /%}} | ||
</div> | ||
</div> | ||
|
||
|
||
## 2. Create a table | ||
|
||
Create a keyspace called 'myapp'. | ||
|
||
```sql | ||
cqlsh> CREATE KEYSPACE myapp; | ||
``` | ||
|
||
|
||
Create a table named 'stock_market' which can store stock prices at various timestamps for different stock ticker symbols. | ||
|
||
```sql | ||
cqlsh> CREATE TABLE myapp.stock_market ( | ||
stock_symbol text, | ||
ts text, | ||
current_price float, | ||
PRIMARY KEY (stock_symbol, ts) | ||
); | ||
``` | ||
|
||
|
||
## 3. Insert data | ||
|
||
Let us insert some data for a few stock symbols into our newly created 'stock_market' table. You can copy-paste these values directly into your cqlsh shell. | ||
|
||
```sql | ||
cqlsh> INSERT INTO myapp.stock_market (stock_symbol,ts,current_price) VALUES ('AAPL','2017-10-26 09:00:00',157.41); | ||
INSERT INTO myapp.stock_market (stock_symbol,ts,current_price) VALUES ('AAPL','2017-10-26 10:00:00',157); | ||
``` | ||
|
||
```sql | ||
cqlsh> INSERT INTO myapp.stock_market (stock_symbol,ts,current_price) VALUES ('FB','2017-10-26 09:00:00',170.63); | ||
INSERT INTO myapp.stock_market (stock_symbol,ts,current_price) VALUES ('FB','2017-10-26 10:00:00',170.1); | ||
``` | ||
|
||
```sql | ||
cqlsh> INSERT INTO myapp.stock_market (stock_symbol,ts,current_price) VALUES ('GOOG','2017-10-26 09:00:00',972.56); | ||
INSERT INTO myapp.stock_market (stock_symbol,ts,current_price) VALUES ('GOOG','2017-10-26 10:00:00',971.91); | ||
``` | ||
|
||
## 4. Query the table | ||
|
||
Query all the values we have inserted into the database for the stock symbol 'AAPL' as follows. | ||
|
||
```sql | ||
cqlsh> SELECT * FROM myapp.stock_market WHERE stock_symbol = 'AAPL'; | ||
``` | ||
|
||
``` | ||
stock_symbol | ts | current_price | ||
--------------+---------------------+--------------- | ||
AAPL | 2017-10-26 09:00:00 | 157.41 | ||
AAPL | 2017-10-26 10:00:00 | 157 | ||
(2 rows) | ||
``` | ||
|
||
|
||
Query all the values for 'FB' and 'GOOG' as follows. | ||
|
||
```sql | ||
cqlsh> SELECT * FROM myapp.stock_market WHERE stock_symbol in ('FB', 'GOOG'); | ||
``` | ||
|
||
``` | ||
stock_symbol | ts | current_price | ||
--------------+---------------------+--------------- | ||
FB | 2017-10-26 09:00:00 | 170.63 | ||
FB | 2017-10-26 10:00:00 | 170.10001 | ||
GOOG | 2017-10-26 09:00:00 | 972.56 | ||
GOOG | 2017-10-26 10:00:00 | 971.90997 | ||
(4 rows) | ||
``` |
29 changes: 29 additions & 0 deletions
29
content/latest/api/ycql/quick-start/binary/explore-ycql.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
--- | ||
|
||
- Run cqlsh to connect to the service. | ||
|
||
You can do this as shown below. | ||
|
||
```sh | ||
$ ./bin/cqlsh localhost | ||
``` | ||
|
||
``` | ||
Connected to local cluster at 127.0.0.1:9042. | ||
[cqlsh 5.0.1 | Cassandra 3.9-SNAPSHOT | CQL spec 3.4.2 | Native protocol v4] | ||
Use HELP for help. | ||
cqlsh> | ||
``` | ||
|
||
- Run a cql command to verify it is working. | ||
|
||
```sql | ||
cqlsh> describe keyspaces; | ||
``` | ||
|
||
``` | ||
system_schema system_auth system | ||
cqlsh> | ||
``` |
29 changes: 29 additions & 0 deletions
29
content/latest/api/ycql/quick-start/docker/explore-ycql.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
--- | ||
|
||
- Run cqlsh to connect to the service. | ||
|
||
You can do this as shown below. | ||
|
||
```sh | ||
$ docker exec -it yb-tserver-n3 /home/yugabyte/bin/cqlsh | ||
``` | ||
|
||
``` | ||
Connected to local cluster at 127.0.0.1:9042. | ||
[cqlsh 5.0.1 | Cassandra 3.9-SNAPSHOT | CQL spec 3.4.2 | Native protocol v4] | ||
Use HELP for help. | ||
cqlsh> | ||
``` | ||
|
||
- Run a cql command to verify it is working. | ||
|
||
```sql | ||
cqlsh> describe keyspaces; | ||
``` | ||
|
||
``` | ||
system_schema system_auth system | ||
cqlsh> | ||
``` |
27 changes: 27 additions & 0 deletions
27
content/latest/api/ycql/quick-start/kubernetes/explore-ycql.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
--- | ||
|
||
- Run cqlsh to connect to the service. | ||
|
||
```sh | ||
$ kubectl exec -it yb-tserver-0 /home/yugabyte/bin/cqlsh | ||
``` | ||
|
||
``` | ||
Connected to local cluster at 127.0.0.1:9042. | ||
[cqlsh 5.0.1 | Cassandra 3.9-SNAPSHOT | CQL spec 3.4.2 | Native protocol v4] | ||
Use HELP for help. | ||
cqlsh> | ||
``` | ||
|
||
- Run a cql command to verify it is working. | ||
|
||
```sql | ||
cqlsh> describe keyspaces; | ||
``` | ||
|
||
``` | ||
system_schema system_auth system | ||
cqlsh> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.