I used the following DDL command to create a table in gcloud spanner database named "messages" in the "guestbook" spanner instance
gcloud spanner databases ddl update messages \
--instance=guestbook --ddl="$(<~/guestbook-service/db/spanner.ddl)"
spanner.ddl contains the following
CREATE TABLE guestbook_message (
id STRING(36) NOT NULL,
name STRING(255) NOT NULL,
image_uri STRING(255),
message STRING(255)
) PRIMARY KEY (id);
But I get the following error.
ERROR: gcloud crashed (ValueError): Invalid header value b'/usr/bin/../lib/google-cloud-sdk/lib/gcloud.py spanner databases ddl update messages --instance=guestbook --d dl=CREATE TABLE guestbook_message (\n id STRING(36) NOT NULL,\n name STRING(255) NOT NULL,\n image_uri STRING(255),\n message STRING(255)\n) PRIMARY KEY (id );'
How can I fix this?
This gcloud command is not accepting ddl statements with new line character
\n
.It is enough to change
spanner.ddl
to:If all is in one line, without those
\n
it works fine.