@snippet
def client_run_sync_query_w_param(client, _):
 QUERY_W_PARAM = 'SELECT name FROM `bigquery-public-data.usa_names.usa_1910_2013` WHERE state = @state'
 LIMIT = 100
 LIMITED = ('%s LIMIT %d' % (QUERY_W_PARAM, LIMIT))
 TIMEOUT_MS = 1000
 from google.cloud.bigquery import ScalarQueryParameter
 param = ScalarQueryParameter('state', 'STRING', 'TX')
 query = client.run_sync_query(LIMITED, query_parameters=[param])
 query.use_legacy_sql = False
 query.timeout_ms = TIMEOUT_MS
 query.run()
 assert query.complete
 assert (len(query.rows) == LIMIT)
 assert ([field.name for field in query.schema] == ['name'])

@ snippet def client_run_sync_query_w_param ( client , _ ) : QUERY_W_PARAM = 'SELECT name FROM `bigquery-public-data.usa_names.usa_1910_2013` WHERE state = @state' LIMIT = 100 LIMITED = ( '%s LIMIT %d' % ( QUERY_W_PARAM , LIMIT ) ) TIMEOUT_MS = 1000 from google . cloud . bigquery import ScalarQueryParameter param = ScalarQueryParameter ( 'state' , 'STRING' , 'TX' ) query = client . run_sync_query ( LIMITED , query_parameters = [ param ] ) query . use_legacy_sql = False query . timeout_ms = TIMEOUT_MS query . run ( ) assert query . complete assert ( len ( query . rows ) == LIMIT ) assert ( [ field . name for field in query . schema ] == [ 'name' ] )
run a synchronous query using a query parameter .