Skip to content

Commit cd34847

Browse files
authored
Add Datatypes examples to Spanner sample. [(#2251)](GoogleCloudPlatform/python-docs-samples#2251)
* Add Datatypes examples to Spanner sample. * Lint. * Lint. * Fix test.
1 parent 7519b11 commit cd34847

File tree

3 files changed

+535
-4
lines changed

3 files changed

+535
-4
lines changed

samples/samples/README.rst

Lines changed: 119 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,30 @@ To run this sample:
7878
7979
usage: snippets.py [-h] [--database-id DATABASE_ID]
8080
instance_id
81-
{create_database,insert_data,query_data,read_data,read_stale_data,add_column,update_data,query_data_with_new_column,read_write_transaction,read_only_transaction,add_index,query_data_with_index,read_data_with_index,add_storing_index,read_data_with_storing_index,create_table_with_timestamp,insert_data_with_timestamp,add_timestamp_column,update_data_with_timestamp,query_data_with_timestamp}
81+
{create_database,insert_data,query_data,read_data,
82+
read_stale_data,add_column,update_data,
83+
query_data_with_new_column,read_write_transaction,
84+
read_only_transaction,add_index,query_data_with_index,
85+
read_data_with_index,add_storing_index,
86+
read_data_with_storing_index,
87+
create_table_with_timestamp,insert_data_with_timestamp,
88+
add_timestamp_column,update_data_with_timestamp,
89+
query_data_with_timestamp,write_struct_data,
90+
query_with_struct,query_with_array_of_struct,
91+
query_struct_field,query_nested_struct_field,
92+
insert_data_with_dml,update_data_with_dml,
93+
delete_data_with_dml,update_data_with_dml_timestamp,
94+
dml_write_read_transaction,update_data_with_dml_struct,
95+
insert_with_dml,query_data_with_parameter,
96+
write_with_dml_transaction,
97+
update_data_with_partitioned_dml,
98+
delete_data_with_partitioned_dml,update_with_batch_dml,
99+
create_table_with_datatypes,insert_datatypes_data,
100+
query_data_with_array,query_data_with_bool,
101+
query_data_with_bytes,query_data_with_date,
102+
query_data_with_float,query_data_with_int,
103+
query_data_with_string,
104+
query_data_with_timestamp_parameter}
82105
...
83106
84107
This application demonstrates how to do basic operations using Cloud
@@ -88,11 +111,32 @@ To run this sample:
88111
89112
positional arguments:
90113
instance_id Your Cloud Spanner instance ID.
91-
{create_database,insert_data,query_data,read_data,read_stale_data,add_column,update_data,query_data_with_new_column,read_write_transaction,read_only_transaction,add_index,query_data_with_index,read_data_with_index,add_storing_index,read_data_with_storing_index,create_table_with_timestamp,insert_data_with_timestamp,add_timestamp_column,update_data_with_timestamp,query_data_with_timestamp}
114+
{create_database, insert_data, delete_data, query_data, read_data,
115+
read_stale_data, add_column, update_data, query_data_with_new_column,
116+
read_write_transaction, read_only_transaction, add_index,
117+
query_data_with_index, read_data_with_index, add_storing_index,
118+
read_data_with_storing_index, create_table_with_timestamp,
119+
insert_data_with_timestamp, add_timestamp_column,
120+
update_data_with_timestamp, query_data_with_timestamp,
121+
write_struct_data, query_with_struct, query_with_array_of_struct,
122+
query_struct_field, query_nested_struct_field, insert_data_with_dml,
123+
update_data_with_dml, delete_data_with_dml,
124+
update_data_with_dml_timestamp, dml_write_read_transaction,
125+
update_data_with_dml_struct, insert_with_dml, query_data_with_parameter,
126+
write_with_dml_transaction, update_data_with_partitioned_dml,
127+
delete_data_with_partitioned_dml, update_with_batch_dml,
128+
create_table_with_datatypes, insert_datatypes_data,
129+
query_data_with_array, query_data_with_bool, query_data_with_bytes,
130+
query_data_with_date, query_data_with_float, query_data_with_int,
131+
query_data_with_string, query_data_with_timestamp_parameter}
92132
create_database Creates a database and tables for sample data.
93133
insert_data Inserts sample data into the given database. The
94134
database and table must already exist and can be
95135
created using `create_database`.
136+
delete_data Deletes sample data from the given database. The
137+
database, table, and data must already exist and
138+
can be created using `create_database` and
139+
`insert_data`.
96140
query_data Queries sample data from the database using SQL.
97141
read_data Reads sample data from the database.
98142
read_stale_data Reads sample data from the database. The data is
@@ -173,6 +217,79 @@ To run this sample:
173217
by running this DDL statement against your database:
174218
ALTER TABLE Performances ADD COLUMN LastUpdateTime
175219
TIMESTAMP OPTIONS (allow_commit_timestamp=true)
220+
write_struct_data Inserts sample data that can be used to test STRUCT
221+
parameters in queries.
222+
query_with_struct Query a table using STRUCT parameters.
223+
query_with_array_of_struct
224+
Query a table using an array of STRUCT parameters.
225+
query_struct_field Query a table using field access on a STRUCT
226+
parameter.
227+
query_nested_struct_field
228+
Query a table using nested field access on a STRUCT
229+
parameter.
230+
insert_data_with_dml
231+
Inserts sample data into the given database using a
232+
DML statement.
233+
update_data_with_dml
234+
Updates sample data from the database using a DML
235+
statement.
236+
delete_data_with_dml
237+
Deletes sample data from the database using a DML
238+
statement.
239+
update_data_with_dml_timestamp
240+
Updates data with Timestamp from the database using
241+
a DML statement.
242+
dml_write_read_transaction
243+
First inserts data then reads it from within a
244+
transaction using DML.
245+
update_data_with_dml_struct
246+
Updates data with a DML statement and STRUCT
247+
parameters.
248+
insert_with_dml Inserts data with a DML statement into the
249+
database.
250+
query_data_with_parameter
251+
Queries sample data from the database using SQL
252+
with a parameter.
253+
write_with_dml_transaction
254+
Transfers part of a marketing budget from one
255+
album to another.
256+
update_data_with_partitioned_dml
257+
Update sample data with a partitioned DML
258+
statement.
259+
delete_data_with_partitioned_dml
260+
Delete sample data with a partitioned DML
261+
statement.
262+
update_with_batch_dml
263+
Updates sample data in the database using Batch
264+
DML.
265+
create_table_with_datatypes
266+
Creates a table with supported dataypes.
267+
insert_datatypes_data
268+
Inserts data with supported datatypes into a table.
269+
query_data_with_array
270+
Queries sample data using SQL with an ARRAY
271+
parameter.
272+
query_data_with_bool
273+
Queries sample data using SQL with a BOOL
274+
parameter.
275+
query_data_with_bytes
276+
Queries sample data using SQL with a BYTES
277+
parameter.
278+
query_data_with_date
279+
Queries sample data using SQL with a DATE
280+
parameter.
281+
query_data_with_float
282+
Queries sample data using SQL with a FLOAT64
283+
parameter.
284+
query_data_with_int
285+
Queries sample data using SQL with a INT64
286+
parameter.
287+
query_data_with_string
288+
Queries sample data using SQL with a STRING
289+
parameter.
290+
query_data_with_timestamp_parameter
291+
Queries sample data using SQL with a TIMESTAMP
292+
parameter.
176293
177294
optional arguments:
178295
-h, --help show this help message and exit

0 commit comments

Comments
 (0)