This page has instructions for running against CockroachDB from various programming languages.
Before you begin
Make sure you have already:
- Set up a .
- .
- .
- that you now want to run queries against.
When running under the default isolation level, your application should that can occur under .
Run a transaction
For more information about how to use the built-in SQL client, see the reference docs. The best way to run a multi-statement transaction from Go code is to use one of the following approaches:
- Use the
crdb transaction wrapper which automatically handles transaction retry errors if they occur, as shown in .
- Write your own retry loop wrapper, as shown in
The best way to run a multi-statement transaction from Java is to write a wrapper method that automatically handles transaction retry errors.For complete examples showing how to write and use such wrapper methods, see .
The best way to run a multi-statement transaction from Python code is to use one of the following approaches:
- Use the sqlalchemy-cockroachdb SQLAlchemy dialect, which automatically handles transaction retry errors if they occur, as shown in .
- Write your own retry loop wrapper, as shown in .
See also
Reference information related to this task:
Other common tasks: