{"id":13721428,"url":"https://github.com/cloudspannerecosystem/spanner-cli","last_synced_at":"2026-02-05T09:10:12.524Z","repository":{"id":38205315,"uuid":"152699846","full_name":"cloudspannerecosystem/spanner-cli","owner":"cloudspannerecosystem","description":"Interactive command line tool for Cloud Spanner","archived":false,"fork":false,"pushed_at":"2025-11-20T02:09:48.000Z","size":884,"stargazers_count":244,"open_issues_count":20,"forks_count":37,"subscribers_count":5,"default_branch":"master","last_synced_at":"2026-01-29T00:58:47.624Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloudspannerecosystem.png","metadata":{"files":{"readme":"README.md","changelog":"Changes.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-10-12T05:45:47.000Z","updated_at":"2025-12-12T02:29:03.000Z","dependencies_parsed_at":"2024-03-12T09:28:08.373Z","dependency_job_id":"714509ee-cf95-4c42-90bc-01618e285790","html_url":"https://github.com/cloudspannerecosystem/spanner-cli","commit_stats":null,"previous_names":[],"tags_count":61,"template":false,"template_full_name":null,"purl":"pkg:github/cloudspannerecosystem/spanner-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudspannerecosystem%2Fspanner-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudspannerecosystem%2Fspanner-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudspannerecosystem%2Fspanner-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudspannerecosystem%2Fspanner-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudspannerecosystem","download_url":"https://codeload.github.com/cloudspannerecosystem/spanner-cli/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudspannerecosystem%2Fspanner-cli/sbom","scorecard":{"id":293291,"data":{"date":"2025-08-11","repo":{"name":"github.com/cloudspannerecosystem/spanner-cli","commit":"0d0904f873b0712f3114ff62728281b7dc0e9092"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.9,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":9,"reason":"Found 29/30 approved changesets -- score normalized to 9","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":1,"reason":"1 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/run-tests.yaml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/run-tests.yaml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/cloudspannerecosystem/spanner-cli/run-tests.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/run-tests.yaml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/cloudspannerecosystem/spanner-cli/run-tests.yaml/master?enable=pin","Warn: containerImage not pinned by hash: Dockerfile:2","Warn: containerImage not pinned by hash: Dockerfile:9: pin your Docker image by updating gcr.io/distroless/static-debian12 to gcr.io/distroless/static-debian12@sha256:2e114d20aa6371fd271f854aa3d6b2b7d2e70e797bb3ea44fb677afec60db22c","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 containerImage dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":1,"reason":"SAST tool is not run on all commits -- score normalized to 1","details":["Warn: 3 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T18:51:38.369Z","repository_id":38205315,"created_at":"2025-08-17T18:51:38.369Z","updated_at":"2025-08-17T18:51:38.369Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29117919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T05:31:32.482Z","status":"ssl_error","status_checked_at":"2026-02-05T05:31:29.075Z","response_time":65,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T01:01:16.926Z","updated_at":"2026-02-05T09:10:12.499Z","avatar_url":"https://github.com/cloudspannerecosystem.png","language":"Go","funding_links":[],"categories":["Tools","Go"],"sub_categories":["ORM"],"readme":"spanner-cli [![run-tests](https://github.com/cloudspannerecosystem/spanner-cli/actions/workflows/run-tests.yaml/badge.svg)](https://github.com/cloudspannerecosystem/spanner-cli/actions/workflows/run-tests.yaml)\n===\n\nInteractive command line tool for Cloud Spanner.\n\n![gif](https://github.com/cloudspannerecosystem/spanner-cli/blob/master/image/spanner_cli.gif)\n\n## Description\n\n`spanner-cli` is an interactive command line tool for [Google Cloud Spanner](https://cloud.google.com/spanner/).  \nYou can control your Spanner databases with idiomatic SQL commands.\n\n## Install\n\n[Install Go](https://go.dev/doc/install) and run the following command.\n\n```\n# For Go 1.16+\ngo install github.com/cloudspannerecosystem/spanner-cli@latest\n```\n\nOr you can build a docker image.\n\n```\ngit clone https://github.com/cloudspannerecosystem/spanner-cli.git\ncd spanner-cli\ndocker build -t spanner-cli .\n```\n\n## Usage\n\n```\nUsage:\n  spanner-cli [OPTIONS]\n\nspanner:\n  -p, --project=               (required) GCP Project ID. [$SPANNER_PROJECT_ID]\n  -i, --instance=              (required) Cloud Spanner Instance ID [$SPANNER_INSTANCE_ID]\n  -d, --database=              (required) Cloud Spanner Database ID. [$SPANNER_DATABASE_ID]\n  -e, --execute=               Execute SQL statement and quit.\n  -f, --file=                  Execute SQL statement from file and quit.\n  -t, --table                  Display output in table format for batch mode.\n  -v, --verbose                Display verbose output.\n      --credential=            Use the specific credential file\n      --prompt=                Set the prompt to the specified format\n      --history=               Set the history file to the specified path\n      --priority=              Set default request priority (HIGH|MEDIUM|LOW)\n      --role=                  Use the specific database role\n      --endpoint=              Set the Spanner API endpoint (host:port)\n      --directed-read=         Directed read option (replica_location:replica_type). The replicat_type is optional and either READ_ONLY or READ_WRITE\n      --skip-tls-verify        Insecurely skip TLS verify\n      --proto-descriptor-file= Path of a file that contains a protobuf-serialized google.protobuf.FileDescriptorSet message to use in this invocation.\n      --version                Show version of spanner-cli\n\nHelp Options:\n  -h, --help                   Show this help message\n```\n\n### Authentication\n\nUnless you specify a credential file with `--credential`, this tool uses [Application Default Credentials](https://cloud.google.com/docs/authentication/production?hl=en#providing_credentials_to_your_application) as credential source to connect to Spanner databases.  \n\nPlease make sure to prepare your credential by `gcloud auth application-default login`.\n\nIf you're running spanner-cli in docker container on your local machine, you have to pass local credentials to the container with the following command.\n\n```\ndocker run -it \\\n  -e GOOGLE_APPLICATION_CREDENTIALS=/tmp/credentials.json \\\n  -v $HOME/.config/gcloud/application_default_credentials.json:/tmp/credentials.json:ro \\\n  spanner-cli --help\n```\n\n## Example\n\n### Interactive mode\n\n```\n$ spanner-cli -p myproject -i myinstance -d mydb\nConnected.\nspanner\u003e CREATE TABLE users (\n      -\u003e   id INT64 NOT NULL,\n      -\u003e   name STRING(16) NOT NULL,\n      -\u003e   active BOOL NOT NULL\n      -\u003e ) PRIMARY KEY (id);\nQuery OK, 0 rows affected (30.60 sec)\n\nspanner\u003e SHOW TABLES;\n+----------------+\n| Tables_in_mydb |\n+----------------+\n| users          |\n+----------------+\n1 rows in set (18.66 msecs)\n\nspanner\u003e INSERT INTO users (id, name, active) VALUES (1, \"foo\", true), (2, \"bar\", false);\nQuery OK, 2 rows affected (5.08 sec)\n\nspanner\u003e SELECT * FROM users ORDER BY id ASC;\n+----+------+--------+\n| id | name | active |\n+----+------+--------+\n| 1  | foo  | true   |\n| 2  | bar  | false  |\n+----+------+--------+\n2 rows in set (3.09 msecs)\n\nspanner\u003e BEGIN;\nQuery OK, 0 rows affected (0.02 sec)\n\nspanner(rw txn)\u003e DELETE FROM users WHERE active = false;\nQuery OK, 1 rows affected (0.61 sec)\n\nspanner(rw txn)\u003e COMMIT;\nQuery OK, 0 rows affected (0.20 sec)\n\nspanner\u003e SELECT * FROM users ORDER BY id ASC;\n+----+------+--------+\n| id | name | active |\n+----+------+--------+\n| 1  | foo  | true   |\n+----+------+--------+\n1 rows in set (2.58 msecs)\n\nspanner\u003e DROP TABLE users;\nQuery OK, 0 rows affected (25.20 sec)\n\nspanner\u003e SHOW TABLES;\nEmpty set (2.02 msecs)\n\nspanner\u003e EXIT;\nBye\n```\n\n### Batch mode\n\nBy passing SQL from standard input, `spanner-cli` runs in batch mode.\n\n```\n$ echo 'SELECT * FROM users;' | spanner-cli -p myproject -i myinstance -d mydb\nid      name    active\n1       foo     true\n2       bar     false\n```\n\nYou can also pass SQL with command line option `-e`.\n\n```\n$ spanner-cli -p myproject -i myinstance -d mydb -e 'SELECT * FROM users;'\nid      name    active\n1       foo     true\n2       bar     false\n```\n\nWith `-t` option, results are displayed in table format.\n\n```\n$ spanner-cli -p myproject -i myinstance -d mydb -e 'SELECT * FROM users;' -t\n+----+------+--------+\n| id | name | active |\n+----+------+--------+\n| 1  | foo  | true   |\n| 2  | bar  | false  |\n+----+------+--------+\n```\n\n### Directed reads mode\n\nspanner-cli now supports directed reads, a feature that allows you to read data from a specific replica of a Spanner database. \nTo use directed reads with spanner-cli, you need to specify the `--directed-read` flag.\nThe `--directed-read` flag takes a single argument, which is the name of the replica that you want to read from.\nThe replica name can be specified in one of the following formats:\n\n- `\u003creplica_location\u003e`\n- `\u003creplica_location\u003e:\u003creplica_type\u003e`\n\nThe `\u003creplica_location\u003e` specifies the region where the replica is located such as `us-central1`, `asia-northeast2`.  \nThe `\u003creplica_type\u003e` specifies the type of the replica either `READ_WRITE` or `READ_ONLY`. \n \n```\n$ spanner-cli -p myproject -i myinstance -d mydb --directed-read us-central1\n\n$ spanner-cli -p myproject -i myinstance -d mydb --directed-read us-central1:READ_ONLY\n\n$ spanner-cli -p myproject -i myinstance -d mydb --directed-read asia-northeast2:READ_WRITE\n```\n\nDirected reads are only effective for single queries or queries within a read-only transaction.\nPlease note that directed read options do not apply to queries within a read-write transaction.\n\n\u003e [!NOTE]\n\u003e If you specify an incorrect region or type for directed reads, directed reads will not be enabled and [your requsts won't be routed as expected](https://cloud.google.com/spanner/docs/directed-reads#parameters). For example, in a multi-region configuration `nam3`, if you mistype `us-east1` as `us-east-1`, the connection will succeed, but directed reads will not be enabled. \n\u003e\n\u003e To perform directed reads to `asia-northeast2` in a multi-region configuration `asia1`, you need to specify `asia-northeast2` or `asia-northeast2:READ_WRITE`.\n\u003e Since the replicas placed in `asia-northeast2` are READ_WRITE replicas, directed reads will not be enabled if you specify `asia-northeast2:READ_ONLY`.\n\u003e \n\u003e Please refer to [the Spanner documentation](https://cloud.google.com/spanner/docs/instance-configurations#available-configurations-multi-region) to verify the valid configurations.\n\n## Syntax\n\nIn the following syntax, we use `\u003c\u003e` for a placeholder, `[]` for an optional keyword,\nand `{}` for a mutually exclusive keyword.\n\n* The syntax is case-insensitive.\n* `\\G` delimiter is also supported for displaying results vertically.\n\n| Usage | Syntax | Note |\n| --- | --- | --- |\n| List databases | `SHOW DATABASES;` | |\n| Switch database | `USE \u003cdatabase\u003e [ROLE \u003crole\u003e];` | The role you set is used for accessing with [fine-grained access control](https://cloud.google.com/spanner/docs/fgac-about). |\n| Create database | `CREATE DATABSE \u003cdatabase\u003e;` | |\n| Drop database | `DROP DATABASE \u003cdatabase\u003e;` | |\n| List tables | `SHOW TABLES [\u003cschema\u003e];` | If schema is not provided, default schema is used |\n| Show table schema | `SHOW CREATE TABLE \u003ctable\u003e;` | The table can be a FQN.|\n| Show columns | `SHOW COLUMNS FROM \u003ctable\u003e;` | The table can be a FQN.|\n| Show indexes | `SHOW INDEX FROM \u003ctable\u003e;` | The table can be a FQN.|\n| Create table | `CREATE TABLE ...;` | |\n| Change table schema | `ALTER TABLE ...;` | |\n| Delete table | `DROP TABLE ...;` | |\n| Truncate table | `TRUNCATE TABLE \u003ctable\u003e;` | Only rows are deleted. Note: Non-atomically because executed as a [partitioned DML statement](https://cloud.google.com/spanner/docs/dml-partitioned?hl=en). |\n| Create index | `CREATE INDEX ...;` | |\n| Delete index | `DROP INDEX ...;` | |\n| Create role | `CREATE ROLE ...;` | |\n| Drop role | `DROP ROLE ...;` | |\n| Grant | `GRANT ...;` | |\n| Revoke | `REVOKE ...;` | |\n| Query | `SELECT ...;` | |\n| DML | `{INSERT\\|UPDATE\\|DELETE} ...;` | |\n| Partitioned DML | `PARTITIONED {UPDATE\\|DELETE} ...;` | |\n| Show Query Execution Plan | `EXPLAIN SELECT ...;` | |\n| Show DML Execution Plan | `EXPLAIN {INSERT\\|UPDATE\\|DELETE} ...;` | |\n| Show Query Execution Plan with Stats | `EXPLAIN ANALYZE SELECT ...;` | |\n| Show DML Execution Plan with Stats | `EXPLAIN ANALYZE {INSERT\\|UPDATE\\|DELETE} ...;` | |\n| Show Query Result Shape | `DESCRIBE SELECT ...;` | |\n| Show DML Result Shape | `DESCRIBE {INSERT\\|UPDATE\\|DELETE} ... THEN RETURN ...;` | |\n| Start a new query optimizer statistics package construction | `ANALYZE;` | |\n| Start Read-Write Transaction | `BEGIN [RW] [ISOLATION LEVEL {SERIALIZABLE\\|REPEATABLE READ}] [PRIORITY {HIGH\\|MEDIUM\\|LOW}] [TAG \u003ctag\u003e];` | See [Isolation Level](#isolation-level) for details on the isolation level. See [Request Priority](#request-priority) for details on the priority. The tag you set is used as both transaction tag and request tag. See also [Transaction Tags and Request Tags](#transaction-tags-and-request-tags).|\n| Commit Read-Write Transaction | `COMMIT;` | |\n| Rollback Read-Write Transaction | `ROLLBACK;` | |\n| Start Read-Only Transaction | `BEGIN RO [{\u003cseconds\u003e\\|\u003cRFC3339-formatted time\u003e}] [PRIORITY {HIGH\\|MEDIUM\\|LOW}] [TAG \u003ctag\u003e];` | `\u003cseconds\u003e` and `\u003cRFC3339-formatted time\u003e` is used for stale read. See [Request Priority](#request-priority) for details on the priority. The tag you set is used as request tag. See also [Transaction Tags and Request Tags](#transaction-tags-and-request-tags).|\n| End Read-Only Transaction | `CLOSE;` | |\n| Exit CLI | `EXIT;` | |\n\n## Customize prompt\n\nYou can customize the prompt by `--prompt` option.  \nThere are some defined variables for being used in prompt.\n\nVariables:\n\n* `\\p` : GCP Project ID\n* `\\i` : Cloud Spanner Instance ID\n* `\\d` : Cloud Spanner Database ID\n* `\\t` : In transaction\n\nExample:\n\n```\n$ spanner-cli -p myproject -i myinstance -d mydb --prompt='[\\p:\\i:\\d]\\t\u003e '\nConnected.\n[myproject:myinstance:mydb]\u003e SELECT * FROM users ORDER BY id ASC;\n+----+------+--------+\n| id | name | active |\n+----+------+--------+\n| 1  | foo  | true   |\n| 2  | bar  | false  |\n+----+------+--------+\n2 rows in set (3.09 msecs)\n\n[myproject:myinstance:mydb]\u003e begin;\nQuery OK, 0 rows affected (0.08 sec)\n\n[myproject:myinstance:mydb](rw txn)\u003e ...\n```\n\nThe default prompt is `spanner\\t\u003e `.\n\n## Config file\n\nThis tool supports a configuration file called `spanner_cli.cnf`, similar to `my.cnf`.  \nThe config file path must be `~/.spanner_cli.cnf`.  \nIn the config file, you can set default option values for command line options.\n\nExample:\n\n```conf\n[spanner]\nproject = myproject\ninstance = myinstance\nprompt = \"[\\\\p:\\\\i:\\\\d]\\\\t\u003e \"\n```\n\n## Configuration Precedence\n\n1. Command line flags(highest)\n2. Environment variables\n3. `.spanner_cli.cnf` in current directory\n4. `.spanner_cli.cnf` in home directory(lowest)\n\n## Isolation Level\n\nYou can set the isolation level at a transaction level in read-write transactions. By default `SERIALIZABLE` isolation is used for every request.\n\nTo set the isolation level for a transaction, you can use the `ISOLATION LEVEL {SERIALIZABLE|REPEATABLE READ}` keyword.\n\nHere are some examples for transaction-level isolation.\n\n```\n# Read-write transaction with serializable isolation\nBEGIN RW ISOLATION LEVEL SERIALIZABLE\n\n# Read-write transaction with repeatable read isolation\nBEGIN RW ISOLATION LEVEL REPEATABLE READ\n```\n\nNote that the transaction-level isolation level cannot be set on read-only transactions.\n\n## Request Priority\n\nYou can set [request priority](https://cloud.google.com/spanner/docs/reference/rest/v1/RequestOptions#Priority) for command level or transaction level.\nBy default `MEDIUM` priority is used for every request.\n\nTo set a priority for command line level, you can use `--priority={HIGH|MEDIUM|LOW}` command line option.\n\nTo set a priority for transaction level, you can use the `PRIORITY {HIGH|MEDIUM|LOW}` keyword.\n\nHere are some examples for transaction-level priority.\n\n```\n# Read-write transaction with low priority\nBEGIN PRIORITY LOW;\n\n# Read-only transaction with low priority\nBEGIN RO PRIORITY LOW;\n\n# Read-only transaction with 60s stale read and medium priority\nBEGIN RO 60 PRIORITY MEDIUM;\n\n# Read-only transaction with exact timestamp and medium priority\nBEGIN RO 2021-04-01T23:47:44+00:00 PRIORITY MEDIUM;\n```\n\nNote that transaction-level priority takes precedence over command-level priority.\n\n## Transaction Tags and Request Tags\n\nIn a read-write transaction, you can add a tag following `BEGIN RW TAG \u003ctag\u003e`.\nspanner-cli adds the tag set in `BEGIN RW TAG` as a transaction tag.\nThe tag will also be used as request tags within the transaction.\n\n```\n# Read-write transaction\n# transaction_tag = tx1\n+--------------------+\n| BEGIN RW TAG tx1;  |\n|                    |\n| SELECT val         |\n| FROM tab1      +-----request_tag = tx1\n| WHERE id = 1;      |\n|                    |\n| UPDATE tab1        |\n| SET val = 10   +-----request_tag = tx1\n| WHERE id = 1;      |\n|                    |\n| COMMIT;            |\n+--------------------+\n```\n\nIn a read-only transaction, you can add a tag following `BEGIN RO TAG \u003ctag\u003e`.\nSince read-only transaction doesn't support transaction tag, spanner-cli adds the tag set in `BEGIN RO TAG` as request tags.\n```\n# Read-only transaction\n# transaction_tag = N/A\n+--------------------+\n| BEGIN RO TAG tx2;  |\n|                    |\n| SELECT SUM(val)    |\n| FROM tab1      +-----request_tag = tx2\n| WHERE id = 1;      |\n|                    |\n| CLOSE;             |\n+--------------------+\n```\n\n## Using with the Cloud Spanner Emulator\n\nThis tool supports the [Cloud Spanner Emulator](https://cloud.google.com/spanner/docs/emulator) via the [`SPANNER_EMULATOR_HOST` environment variable](https://cloud.google.com/spanner/docs/emulator#client-libraries).\n\n```sh\n$ export SPANNER_EMULATOR_HOST=localhost:9010\n# Or with gcloud env-init:\n$ $(gcloud emulators spanner env-init)\n\n$ spanner-cli -p myproject -i myinstance -d mydb\n```\n\n## How to develop\n\nRun unit tests.\n\n```\n$ make test\n```\n\nRun integration tests, which connects to real Cloud Spanner database.\n\n```\n$ PROJECT=${PROJECT_ID} INSTANCE=${INSTANCE_ID} DATABASE=${DATABASE_ID} CREDENTIAL=${CREDENTIAL} make test\n```\n\n## TODO\n\n* Show secondary index by \"SHOW CREATE TABLE\"\n\n## Disclaimer\n\nDo not use this tool for production databases as the tool is still alpha quality.\n\nPlease feel free to report issues and send pull requests, but note that this application is not officially supported as part of the Cloud Spanner product.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudspannerecosystem%2Fspanner-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudspannerecosystem%2Fspanner-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudspannerecosystem%2Fspanner-cli/lists"}