PreparedStatement

class borneo.PreparedStatement(sql_text, query_plan, query_schema, topology_info, proxy_statement, driver_plan, num_iterators, num_registers, external_vars, namespace, table_name, operation)[source]

Bases: object

A class encapsulating a prepared query statement. It includes state that can be sent to a server and executed without re-parsing the query. It includes bind variables which may be set for each successive use of the query. The prepared query itself is read-only but this object contains a dictionary of bind variables and is not thread-safe if variables are used.

PreparedStatement instances are returned inside PrepareResult objects returned by NoSQLHandle.prepare()

A single instance of PreparedStatement is thread-safe if bind variables are not used. If bind variables are to be used and the statement shared among threads additional instances of PreparedStatement can be constructed using copy_statement().

Methods Summary

clear_variables() Clears all bind variables from the statement.
copy_statement() Returns a new instance that shares this object’s prepared query, which is immutable, but does not share its variables.
get_query_plan() Returns a string representation of the query execution plan, if it was requested in the PrepareRequest; None otherwise.
get_sql_text() Returns the SQL text of this PreparedStatement.
get_variables() Returns the dictionary of variables to use for a prepared query with variables.
set_variable(variable, value) Binds an external variable to a given value.

Methods Documentation

clear_variables()[source]

Clears all bind variables from the statement.

copy_statement()[source]

Returns a new instance that shares this object’s prepared query, which is immutable, but does not share its variables.

Returns:a new PreparedStatement using this instance’s prepared query. Bind variables are uninitialized.
Return type:PreparedStatement
get_query_plan()[source]

Returns a string representation of the query execution plan, if it was requested in the PrepareRequest; None otherwise.

Returns:the string representation of the query execution plan.
Return type:bool
get_sql_text()[source]

Returns the SQL text of this PreparedStatement.

Returns:the SQL text of this PreparedStatement.
Return type:str
get_variables()[source]

Returns the dictionary of variables to use for a prepared query with variables.

Returns:the dictionary.
Return type:dict
set_variable(variable, value)[source]

Binds an external variable to a given value. The variable is identified by its name or its position within the query string. The variable that appears first in the query text has position 1, the variable that appears second has position 2 and so on.

Parameters:
  • variable (str or int) – the name or the position of the variable.
  • value (a value matching the type of the field) – the value.
Returns:

self.

Raises:

IllegalArgumentException – raises the exception if variable is not a string or positive integer.