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
Copy file name to clipboardexpand all lines: build-a-c++-app-with-cockroachdb.md
+8-7
Original file line number
Diff line number
Diff line change
@@ -21,11 +21,13 @@ Install the C++ libpqxx driver as described in the [official documentation](http
21
21
22
22
## Step 5. Run the C++ code
23
23
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
+
24
26
### Basic Statements
25
27
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.
27
29
28
-
Copy the code or
30
+
You can copy the code or
29
31
<ahref="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/basic-sample.cpp"download>download it directly</a>.
30
32
31
33
~~~cpp
@@ -34,18 +36,17 @@ Copy the code or
34
36
35
37
### Transaction (with retry logic)
36
38
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.
41
40
42
41
{{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}}
43
42
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
+
44
45
~~~ cpp
45
46
{% include app/txn-sample.cpp %}
46
47
~~~
47
48
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:
49
50
50
51
~~~shell
51
52
$ cockroach sql -e 'SELECT id, balance FROM accounts' --database=bank
Copy file name to clipboardexpand all lines: build-a-clojure-app-with-cockroachdb.md
+5-3
Original file line number
Diff line number
Diff line change
@@ -34,9 +34,11 @@ CREATE TABLE
34
34
35
35
## Step 6. Run the Clojure code
36
36
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
+
37
39
### Basic Statements
38
40
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.
40
42
41
43
Copy the code or
42
44
<ahref="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
47
49
48
50
### Transaction (with retry logic)
49
51
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.
51
53
52
54
Copy the code or
53
55
<ahref="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
58
60
{% include app/txn-sample.clj %}
59
61
~~~
60
62
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:
62
64
63
65
~~~shell
64
66
$ cockroach sql -e 'SELECT id, balance FROM accounts' --database=bank
Copy file name to clipboardexpand all lines: build-a-go-app-with-cockroachdb.md
+5-4
Original file line number
Diff line number
Diff line change
@@ -30,13 +30,14 @@ $ go get -u github.com/lib/pq
30
30
31
31
## Step 5. Run the Go code
32
32
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
+
33
35
### Basic Statements
34
36
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.
36
38
37
39
Copy the code or
38
40
<ahref="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/basic-sample.go"download>download it directly</a>.
39
-
40
41
~~~go
41
42
{% include app/basic-sample.go %}
42
43
~~~
@@ -57,7 +58,7 @@ Initial balances:
57
58
58
59
### Transaction (with retry logic)
59
60
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.
61
62
62
63
Copy the code or
63
64
<ahref="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:
86
87
Success
87
88
~~~
88
89
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 weretransferred from one account to another, use the [built-in SQL client](use-the-built-in-sql-client.html):
90
91
91
92
~~~shell
92
93
$ cockroach sql -e 'SELECT id, balance FROM accounts' --database=bank
Copy file name to clipboardexpand all lines: build-a-java-app-with-cockroachdb.md
+7-5
Original file line number
Diff line number
Diff line change
@@ -26,11 +26,13 @@ Download and set up the Java jdbc driver as described in the [official documenta
26
26
27
27
## Step 5. Run the Java code
28
28
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
+
29
31
### Basic Statements
30
32
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.
32
34
33
-
Copy the code or
35
+
You can copy the code or
34
36
<ahref="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/BasicSample.java"download>download it directly</a>.
35
37
36
38
~~~java
@@ -39,9 +41,9 @@ Copy the code or
39
41
40
42
### Transaction (with retry logic)
41
43
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.
43
45
44
-
Copy the code or
46
+
You can copy the code or
45
47
<ahref="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/txn-sample.rb"download>download it directly</a>.
46
48
47
49
{{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 <ahref="https://www.cockroachlabs.com/docs/transactions.html#transaction-retries">Transaction Retries</a>.{{site.data.alerts.end}}
@@ -50,7 +52,7 @@ Copy the code or
50
52
{% include app/TxnSample.java %}
51
53
~~~
52
54
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:
54
56
55
57
~~~shell
56
58
$ cockroach sql -e 'SELECT id, balance FROM accounts' --database=bank
Copy file name to clipboardexpand all lines: build-a-nodejs-app-with-cockroachdb.md
+7-5
Original file line number
Diff line number
Diff line change
@@ -30,11 +30,13 @@ $ npm install pg
30
30
31
31
## Step 5. Run the Node.js code
32
32
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
+
33
35
### Basic Statements
34
36
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.
36
38
37
-
Copy the code or
39
+
You can copy the code or
38
40
<ahref="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/basic-sample.js"download>download it directly</a>.
39
41
40
42
~~~js
@@ -43,9 +45,9 @@ Copy the code or
43
45
44
46
### Transaction (with retry logic)
45
47
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.
47
49
48
-
Copy the code or
50
+
You can copy the code or
49
51
<ahref="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/txn-sample.js"download>download it directly</a>.
50
52
51
53
{{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 <ahref="https://www.cockroachlabs.com/docs/transactions.html#transaction-retries">Transaction Retries</a>.{{site.data.alerts.end}}
@@ -54,7 +56,7 @@ Copy the code or
54
56
{% include app/txn-sample.js%}
55
57
~~~
56
58
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:
58
60
59
61
~~~shell
60
62
$ cockroach sql -e 'SELECT id, balance FROM accounts' --database=bank
Copy file name to clipboardexpand all lines: build-a-php-app-with-cockroachdb.md
+7-5
Original file line number
Diff line number
Diff line change
@@ -34,11 +34,13 @@ CREATE TABLE
34
34
35
35
## Step 6. Run the PHP code
36
36
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
+
37
39
### Basic Statements
38
40
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.
40
42
41
-
Copy the code or
43
+
You can copy the code or
42
44
<ahref="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/basic-sample.php"download>download it directly</a>.
43
45
44
46
~~~php
@@ -47,9 +49,9 @@ Copy the code or
47
49
48
50
### Transaction (with retry logic)
49
51
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.
51
53
52
-
Copy the code or
54
+
You can copy the code or
53
55
<ahref="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/txn-sample.php"download>download it directly</a>.
54
56
55
57
{{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 <ahref="https://www.cockroachlabs.com/docs/transactions.html#transaction-retries">Transaction Retries</a>.{{site.data.alerts.end}}
@@ -58,7 +60,7 @@ Copy the code or
58
60
{% include app/txn-sample.php %}
59
61
~~~
60
62
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:
62
64
63
65
~~~shell
64
66
$ cockroach sql -e 'SELECT id, balance FROM accounts' --database=bank
Copy file name to clipboardexpand all lines: build-a-python-app-with-cockroachdb.md
+5-3
Original file line number
Diff line number
Diff line change
@@ -39,9 +39,11 @@ For other ways to install psycopg2, see the [official documentation](http://init
39
39
40
40
## Step 5. Run the Python code
41
41
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
+
42
44
### Basic Statements
43
45
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.
45
47
46
48
Copy the code or
47
49
<ahref="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/basic-sample.py"download>download it directly</a>.
@@ -66,7 +68,7 @@ Initial balances:
66
68
67
69
### Transaction (with retry logic)
68
70
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.
70
72
71
73
Copy the code or
72
74
<ahref="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:
91
93
['2', '350']
92
94
~~~
93
95
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 weretransferred from one account to another, use the [built-in SQL client](use-the-built-in-sql-client.html):
95
97
96
98
~~~shell
97
99
$ cockroach sql -e 'SELECT id, balance FROM accounts' --database=bank
Copy file name to clipboardexpand all lines: build-a-ruby-app-with-cockroachdb.md
+5-3
Original file line number
Diff line number
Diff line change
@@ -30,9 +30,11 @@ $ gem install pg
30
30
31
31
## Step 5. Run the Ruby code
32
32
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
+
33
35
### Basic Statements
34
36
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.
36
38
37
39
Copy the code or
38
40
<ahref="https://raw.githubusercontent.com/cockroachdb/docs/gh-pages/_includes/app/basic-sample.rb"download>download it directly</a>.
@@ -57,7 +59,7 @@ Initial balances:
57
59
58
60
### Transaction (with retry logic)
59
61
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.
61
63
62
64
Copy the code or
63
65
<ahref="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:
74
76
$ ruby txn-sample.rb
75
77
~~~
76
78
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 weretransferred from one account to another, use the [built-in SQL client](use-the-built-in-sql-client.html):
78
80
79
81
~~~ shell
80
82
$ cockroach sql -e 'SELECT id, balance FROM accounts' --database=bank
0 commit comments