Skip to content

Commit 33e8716

Browse files
author
Jesse Seldess
committed
Clarify driver-specific build and app tutorials
Make sequence explicit in "run code" step Fixes cockroachdb#1215
1 parent 12c7e8b commit 33e8716

9 files changed

+56
-40
lines changed

build-a-c++-app-with-cockroachdb.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ Install the C++ libpqxx driver as described in the [official documentation](http
2121

2222
## Step 5. Run the C++ code
2323

24+
Now that you have a database and a user, you'll run code to create a table and insert some rows, and then you'll run code to read and update values as an atomic [transaction](transactions.html).
25+
2426
### Basic Statements
2527

26-
The following code connects as the `maxroach` user and executes some basic SQL statements, creating a table, inserting rows, and reading and printing the rows.
28+
First, use the following code to connect as the `maxroach` user and execute some basic SQL statements, creating a table, inserting rows, and reading and printing the rows.
2729

28-
Copy the code or
30+
You can copy the code or
2931
<a href="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/basic-sample.cpp" download>download it directly</a>.
3032

3133
~~~ cpp
@@ -34,18 +36,17 @@ Copy the code or
3436
3537
### Transaction (with retry logic)
3638
37-
The following code again connects as the `maxroach` user but this time executes a batch of statements as an atomic transaction to transfer funds from one account to another, where all included statements are either committed or aborted.
38-
39-
Copy the code or
40-
<a href="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/txn-sample.cpp" download>download it directly</a>.
39+
Next, use the following code to again connect as the `maxroach` user but this time execute a batch of statements as an atomic transaction to transfer funds from one account to another, where all included statements are either committed or aborted.
4140
4241
{{site.data.alerts.callout_info}}Because the CockroachDB transaction model requires the client to initiate retries in the case of contention, CockroachDB provides a generic <strong>retry function</strong> that runs inside a transaction and retries it as needed. You can copy and paste the retry function from here into your code. For more details, see <a href="https://www.cockroachlabs.com/docs/transactions.html#transaction-retries">Transaction Retries</a>.{{site.data.alerts.end}}
4342
43+
You can copy the code or <a href="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/txn-sample.cpp" download>download it directly</a>.
44+
4445
~~~ cpp
4546
{% include app/txn-sample.cpp %}
4647
~~~
4748

48-
After running the code, to verify that funds were, in fact, transferred from one account to another, you can again use the [built-in SQL client](use-the-built-in-sql-client.html):
49+
After running the code, use the [built-in SQL client](use-the-built-in-sql-client.html) to verify that funds were transferred from one account to another:
4950

5051
~~~ shell
5152
$ cockroach sql -e 'SELECT id, balance FROM accounts' --database=bank

build-a-clojure-app-with-cockroachdb.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ CREATE TABLE
3434

3535
## Step 6. Run the Clojure code
3636

37+
Now that you have a database and a user, you'll run code to create a table and insert some rows, and then you'll run code to read and update values as an atomic [transaction](transactions.html).
38+
3739
### Basic Statements
3840

39-
The following code connects as the `maxroach` user and executes some basic SQL statements, inserting rows and reading and printing the rows.
41+
First, use the following code to connect as the `maxroach` user and execute some basic SQL statements, inserting rows and reading and printing the rows.
4042

4143
Copy the code or
4244
<a href="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/basic-sample.clj" download>download it directly</a>.
@@ -47,7 +49,7 @@ Copy the code or
4749

4850
### Transaction (with retry logic)
4951

50-
The following code again connects as the `maxroach` user but this time executes a batch of statements as an atomic transaction to transfer funds from one account to another, where all included statements are either committed or aborted.
52+
Next, use the following code to again connect as the `maxroach` user but this time execute a batch of statements as an atomic transaction to transfer funds from one account to another, where all included statements are either committed or aborted.
5153

5254
Copy the code or
5355
<a href="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/txn-sample.clj" download>download it directly</a>.
@@ -58,7 +60,7 @@ Copy the code or
5860
{% include app/txn-sample.clj %}
5961
~~~
6062

61-
After running the code, to verify that funds were, in fact, transferred from one account to another, you can again use the [built-in SQL client](use-the-built-in-sql-client.html):
63+
After running the code, use the [built-in SQL client](use-the-built-in-sql-client.html) to verify that funds were transferred from one account to another:
6264

6365
~~~ shell
6466
$ cockroach sql -e 'SELECT id, balance FROM accounts' --database=bank

build-a-go-app-with-cockroachdb.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ $ go get -u github.com/lib/pq
3030

3131
## Step 5. Run the Go code
3232

33+
Now that you have a database and a user, you'll run code to create a table and insert some rows, and then you'll run code to read and update values as an atomic [transaction](transactions.html).
34+
3335
### Basic Statements
3436

35-
The following code connects as the `maxroach` user and executes some basic SQL statements, creating a table, inserting rows, and reading and printing the rows.
37+
First, use the following code to connect as the `maxroach` user and execute some basic SQL statements, creating a table, inserting rows, and reading and printing the rows.
3638

3739
Copy the code or
3840
<a href="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/basic-sample.go" download>download it directly</a>.
39-
4041
~~~ go
4142
{% include app/basic-sample.go %}
4243
~~~
@@ -57,7 +58,7 @@ Initial balances:
5758

5859
### Transaction (with retry logic)
5960

60-
The following code again connects as the `maxroach` user but this time executes a batch of statements as an atomic transaction to transfer funds from one account to another, where all included statements are either committed or aborted.
61+
Next, use the following code to again connect as the `maxroach` user but this time will execute a batch of statements as an atomic transaction to transfer funds from one account to another, where all included statements are either committed or aborted.
6162

6263
Copy the code or
6364
<a href="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/txn-sample.go" download>download it directly</a>.
@@ -86,7 +87,7 @@ The output should just be:
8687
Success
8788
~~~
8889

89-
However, if you want to verify that funds were, in fact, transferred from one account to another, you can again use the [built-in SQL client](use-the-built-in-sql-client.html):
90+
However, if you want to verify that funds were transferred from one account to another, use the [built-in SQL client](use-the-built-in-sql-client.html):
9091

9192
~~~ shell
9293
$ cockroach sql -e 'SELECT id, balance FROM accounts' --database=bank

build-a-java-app-with-cockroachdb.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ Download and set up the Java jdbc driver as described in the [official documenta
2626

2727
## Step 5. Run the Java code
2828

29+
Now that you have a database and a user, you'll run code to create a table and insert some rows, and then you'll run code to read and update values as an atomic [transaction](transactions.html).
30+
2931
### Basic Statements
3032

31-
The following code connects as the `maxroach` user and executes some basic SQL statements, creating a table, inserting rows, and reading and printing the rows.
33+
First, use the following code to connect as the `maxroach` user and execute some basic SQL statements, creating a table, inserting rows, and reading and printing the rows.
3234

33-
Copy the code or
35+
You can copy the code or
3436
<a href="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/BasicSample.java" download>download it directly</a>.
3537

3638
~~~ java
@@ -39,9 +41,9 @@ Copy the code or
3941

4042
### Transaction (with retry logic)
4143

42-
The following code again connects as the `maxroach` user but this time executes a batch of statements as an atomic transaction to transfer funds from one account to another, where all included statements are either committed or aborted.
44+
Next, use the following code to again connect as the `maxroach` user but this time execute a batch of statements as an atomic transaction to transfer funds from one account to another, where all included statements are either committed or aborted.
4345

44-
Copy the code or
46+
You can copy the code or
4547
<a href="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/txn-sample.rb" download>download it directly</a>.
4648

4749
{{site.data.alerts.callout_info}}Because the CockroachDB transaction model requires the client to initiate retries in the case of contention, CockroachDB provides a generic <strong>retry function</strong> that runs inside a transaction and retries it as needed. You can copy and paste the retry function from here into your code. For more details, see <a href="https://www.cockroachlabs.com/docs/transactions.html#transaction-retries">Transaction Retries</a>.{{site.data.alerts.end}}
@@ -50,7 +52,7 @@ Copy the code or
5052
{% include app/TxnSample.java %}
5153
~~~
5254

53-
After running the code, to verify that funds were, in fact, transferred from one account to another, you can again use the [built-in SQL client](use-the-built-in-sql-client.html):
55+
After running the code, use the [built-in SQL client](use-the-built-in-sql-client.html) to verify that funds were transferred from one account to another:
5456

5557
~~~ shell
5658
$ cockroach sql -e 'SELECT id, balance FROM accounts' --database=bank

build-a-nodejs-app-with-cockroachdb.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ $ npm install pg
3030

3131
## Step 5. Run the Node.js code
3232

33+
Now that you have a database and a user, you'll run code to create a table and insert some rows, and then you'll run code to read and update values as an atomic [transaction](transactions.html).
34+
3335
### Basic Statements
3436

35-
The following code connects as the `maxroach` user and executes some basic SQL statements, creating a table, inserting rows, and reading and printing the rows.
37+
First, use the following code to connect as the `maxroach` user and execute some basic SQL statements, creating a table, inserting rows, and reading and printing the rows.
3638

37-
Copy the code or
39+
You can copy the code or
3840
<a href="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/basic-sample.js" download>download it directly</a>.
3941

4042
~~~ js
@@ -43,9 +45,9 @@ Copy the code or
4345

4446
### Transaction (with retry logic)
4547

46-
The following code again connects as the `maxroach` user but this time executes a batch of statements as an atomic transaction to transfer funds from one account to another, where all included statements are either committed or aborted.
48+
Next, use the following code to again connect as the `maxroach` user but this time execute a batch of statements as an atomic transaction to transfer funds from one account to another, where all included statements are either committed or aborted.
4749

48-
Copy the code or
50+
You can copy the code or
4951
<a href="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/txn-sample.js" download>download it directly</a>.
5052

5153
{{site.data.alerts.callout_info}}Because the CockroachDB transaction model requires the client to initiate retries in the case of contention, CockroachDB provides a generic <strong>retry function</strong> that runs inside a transaction and retries it as needed. You can copy and paste the retry function from here into your code. For more details, see <a href="https://www.cockroachlabs.com/docs/transactions.html#transaction-retries">Transaction Retries</a>.{{site.data.alerts.end}}
@@ -54,7 +56,7 @@ Copy the code or
5456
{% include app/txn-sample.js %}
5557
~~~
5658

57-
After running the code, to verify that funds were, in fact, transferred from one account to another, you can again use the [built-in SQL client](use-the-built-in-sql-client.html):
59+
After running the code, use the [built-in SQL client](use-the-built-in-sql-client.html) to verify that funds were transferred from one account to another:
5860

5961
~~~ shell
6062
$ cockroach sql -e 'SELECT id, balance FROM accounts' --database=bank

build-a-php-app-with-cockroachdb.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ CREATE TABLE
3434

3535
## Step 6. Run the PHP code
3636

37+
Now that you have a database and a user, you'll run code to create a table and insert some rows, and then you'll run code to read and update values as an atomic [transaction](transactions.html).
38+
3739
### Basic Statements
3840

39-
The following code connects as the `maxroach` user and executes some basic SQL statements, inserting rows and reading and printing the rows.
41+
First, use the following code to connect as the `maxroach` user and execute some basic SQL statements, inserting rows and reading and printing the rows.
4042

41-
Copy the code or
43+
You can copy the code or
4244
<a href="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/basic-sample.php" download>download it directly</a>.
4345

4446
~~~ php
@@ -47,9 +49,9 @@ Copy the code or
4749

4850
### Transaction (with retry logic)
4951

50-
The following code again connects as the `maxroach` user but this time executes a batch of statements as an atomic transaction to transfer funds from one account to another, where all included statements are either committed or aborted.
52+
Next, use the following code to again connect as the `maxroach` user but this time execute a batch of statements as an atomic transaction to transfer funds from one account to another, where all included statements are either committed or aborted.
5153

52-
Copy the code or
54+
You can copy the code or
5355
<a href="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/txn-sample.php" download>download it directly</a>.
5456

5557
{{site.data.alerts.callout_info}}Because the CockroachDB transaction model requires the client to initiate retries in the case of contention, CockroachDB provides a generic <strong>retry function</strong> that runs inside a transaction and retries it as needed. You can copy and paste the retry function from here into your code. For more details, see <a href="https://www.cockroachlabs.com/docs/transactions.html#transaction-retries">Transaction Retries</a>.{{site.data.alerts.end}}
@@ -58,7 +60,7 @@ Copy the code or
5860
{% include app/txn-sample.php %}
5961
~~~
6062

61-
After running the code, to verify that funds were, in fact, transferred from one account to another, you can again use the [built-in SQL client](use-the-built-in-sql-client.html):
63+
After running the code, use the [built-in SQL client](use-the-built-in-sql-client.html) to verify that funds were transferred from one account to another:
6264

6365
~~~ shell
6466
$ cockroach sql -e 'SELECT id, balance FROM accounts' --database=bank

build-a-python-app-with-cockroachdb.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ For other ways to install psycopg2, see the [official documentation](http://init
3939

4040
## Step 5. Run the Python code
4141

42+
Now that you have a database and a user, you'll run code to create a table and insert some rows, and then you'll run code to read and update values as an atomic [transaction](transactions.html).
43+
4244
### Basic Statements
4345

44-
The following code connects as the `maxroach` user and executes some basic SQL statements, creating a table, inserting rows, and reading and printing the rows.
46+
First, use he following code to connect as the `maxroach` user and execute some basic SQL statements, creating a table, inserting rows, and reading and printing the rows.
4547

4648
Copy the code or
4749
<a href="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/basic-sample.py" download>download it directly</a>.
@@ -66,7 +68,7 @@ Initial balances:
6668

6769
### Transaction (with retry logic)
6870

69-
The following code again connects as the `maxroach` user but this time executes a batch of statements as an atomic transaction to transfer funds from one account to another, where all included statements are either committed or aborted.
71+
Next, use the following code to again connect as the `maxroach` user but this time execute a batch of statements as an atomic transaction to transfer funds from one account to another, where all included statements are either committed or aborted.
7072

7173
Copy the code or
7274
<a href="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/txn-sample.py" download>download it directly</a>.
@@ -91,7 +93,7 @@ Balances after transfer:
9193
['2', '350']
9294
~~~
9395

94-
However, if you want to verify that funds were, in fact, transferred from one account to another, you can again use the [built-in SQL client](use-the-built-in-sql-client.html):
96+
However, if you want to verify that funds were transferred from one account to another, use the [built-in SQL client](use-the-built-in-sql-client.html):
9597

9698
~~~ shell
9799
$ cockroach sql -e 'SELECT id, balance FROM accounts' --database=bank

build-a-ruby-app-with-cockroachdb.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ $ gem install pg
3030

3131
## Step 5. Run the Ruby code
3232

33+
Now that you have a database and a user, you'll run code to create a table and insert some rows, and then you'll run code to read and update values as an atomic [transaction](transactions.html).
34+
3335
### Basic Statements
3436

35-
The following code connects as the `maxroach` user and executes some basic SQL statements, creating a table, inserting rows, and reading and printing the rows.
37+
First, use the following code to connect as the `maxroach` user and execute some basic SQL statements, creating a table, inserting rows, and reading and printing the rows.
3638

3739
Copy the code or
3840
<a href="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/basic-sample.rb" download>download it directly</a>.
@@ -57,7 +59,7 @@ Initial balances:
5759

5860
### Transaction (with retry logic)
5961

60-
The following code again connects as the `maxroach` user but this time executes a batch of statements as an atomic transaction to transfer funds from one account to another, where all included statements are either committed or aborted.
62+
Next, use the following code to again connect as the `maxroach` user but this time execute a batch of statements as an atomic transaction to transfer funds from one account to another, where all included statements are either committed or aborted.
6163

6264
Copy the code or
6365
<a href="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/txn-sample.rb" download>download it directly</a>.
@@ -74,7 +76,7 @@ Then run the code:
7476
$ ruby txn-sample.rb
7577
~~~
7678
77-
To verify that funds were, in fact, transferred from one account to another, you can again use the [built-in SQL client](use-the-built-in-sql-client.html):
79+
To verify that funds were transferred from one account to another, use the [built-in SQL client](use-the-built-in-sql-client.html):
7880
7981
~~~ shell
8082
$ cockroach sql -e 'SELECT id, balance FROM accounts' --database=bank

0 commit comments

Comments
 (0)