mysqlx.SelectStatement¶
-
class
mysqlx.
SelectStatement
(table, *fields)¶ Bases:
mysqlx.statement.ReadStatement
A statement for record retrieval operations on a Table.
- Parameters
table (mysqlx.Table) – The Table object.
*fields – The fields to be retrieved.
-
bind
(*args)¶ Binds value(s) to a specific placeholder(s).
- Parameters
*args – The name of the placeholder and the value to bind. A
mysqlx.DbDoc
object or a JSON string representation can be used.- Returns
FilterableStatement object.
- Return type
- Raises
ProgrammingError – If the number of arguments is invalid.
-
property
changed
¶ True if this statement has changes.
- Type
bool
-
property
deallocate_prepare_execute
¶ True to deallocate + prepare + execute statement.
- Type
bool
-
property
exec_counter
¶ The number of times this statement was executed.
- Type
int
-
execute
()¶ Execute the statement.
- Returns
Result object.
- Return type
-
get_binding_map
()¶ Returns the binding map dictionary.
- Returns
The binding map dictionary.
- Return type
dict
-
get_bindings
()¶ Returns the bindings list.
- Returns
The bindings list.
- Return type
list
-
get_grouping
()¶ Returns the grouping expression list.
- Returns
The grouping expression list.
- Return type
list
-
get_having
()¶ Returns the having expression.
- Returns
The having expression.
- Return type
object
-
get_limit_offset
()¶ Returns the limit offset.
- Returns
The limit offset.
- Return type
int
-
get_limit_row_count
()¶ Returns the limit row count.
- Returns
The limit row count.
- Return type
int
-
get_projection_expr
()¶ Returns the projection expression.
- Returns
The projection expression.
- Return type
object
-
get_sort_expr
()¶ Returns the sort expression.
- Returns
The sort expression.
- Return type
object
-
get_sql
()¶ Returns the generated SQL.
- Returns
The generated SQL.
- Return type
str
-
get_where_expr
()¶ Returns the where expression.
- Returns
The where expression.
- Return type
object
-
group_by
(*fields)¶ Sets a grouping criteria for the resultset.
- Parameters
*fields – The string expressions identifying the grouping criteria.
- Returns
ReadStatement object.
- Return type
-
having
(condition)¶ Sets a condition for records to be considered in agregate function operations.
- Parameters
condition (string) – A condition on the agregate functions used on the grouping criteria.
- Returns
ReadStatement object.
- Return type
-
increment_exec_counter
()¶ Increments the number of times this statement has been executed.
-
is_doc_based
()¶ Check if it is document based.
- Returns
True if it is document based.
- Return type
bool
-
is_lock_exclusive
()¶ Returns True if is EXCLUSIVE LOCK.
- Returns
True if is EXCLUSIVE LOCK.
- Return type
bool
Returns True if is SHARED LOCK.
- Returns
True if is SHARED LOCK.
- Return type
bool
-
limit
(row_count, offset=None)¶ Sets the maximum number of items to be returned.
- Parameters
row_count (int) – The maximum number of items.
- Returns
FilterableStatement object.
- Return type
- Raises
ValueError – If
row_count
is not a positive integer.
Changed in version 8.0.12: The usage of
offset
was deprecated.
-
property
lock_contention
¶ The lock contention value.
- Type
mysqlx.LockContention
-
lock_exclusive
(lock_contention=0)¶ - Execute a read operation with EXCLUSIVE LOCK. Only one lock can be
active at a time.
- Parameters
lock_contention (
mysqlx.LockContention
) – Lock contention.
- Execute a read operation with SHARED LOCK. Only one lock can be
active at a time.
- Parameters
lock_contention (
mysqlx.LockContention
) – Lock contention.
-
offset
(offset)¶ Sets the number of items to skip.
- Parameters
offset (int) – The number of items to skip.
- Returns
FilterableStatement object.
- Return type
- Raises
ValueError – If
offset
is not a positive integer.
New in version 8.0.12.
-
order_by
(*clauses)¶ Sets the order by criteria.
- Parameters
*clauses – The expression strings defining the order by criteria.
- Returns
SelectStatement object.
- Return type
-
property
prepared
¶ True if this statement has been prepared.
- Type
bool
-
property
repeated
¶ True if this statement was executed more than once.
- Type
bool
-
reset_exec_counter
()¶ Resets the number of times this statement has been executed.
-
property
schema
¶ The Schema object.
- Type
-
sort
(*clauses)¶ Sets the sorting criteria.
- Parameters
*clauses – The expression strings defining the sort criteria.
- Returns
FilterableStatement object.
- Return type
Deprecated since version 8.0.12.
-
property
stmt_id
¶ Returns this statement ID.
- Returns
The statement ID.
- Return type
int
-
property
target
¶ The database object target.
- Type
object
-
where
(condition)¶ Sets the search condition to filter.
- Parameters
condition (str) – Sets the search condition to filter records.
- Returns
SelectStatement object.
- Return type