内容
GCPのSpannerデータベースに対してクエリを実行したところ、ERROR: (gcloud.spanner.rows.insert) Error parsing [database].
というエラーが出たので解消法を紹介します。
Error内容
$ gcloud spanner rows insert --database=spanner-database --table=t1 --data=t1=1 --project=project-name
ERROR: (gcloud.spanner.rows.insert) Error parsing [database].
The [database] resource is not properly specified.
Failed to find attribute [instance]. The attribute can be set in the following ways:
- provide the argument `--database` on the command line with a fully specified name
- provide the argument `--instance` on the command line
- set the property `spanner/instance`
原因
instanceを指定していなかったのでエラーになっていました。
解消方法
$ gcloud spanner rows insert --instance=tfgen-spanid-20240502313341 --database=spanner-database --table=t1 --data=t1=1 --project=project-name
commitTimestamp: '2024-05-06T19:42:07.003236Z'
上記のように、--instance
を指定することでエラーが解消されました。