Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

sql.mysql.statement

import sql.mysql.statement

sql lifts part of this module out to its own top level; each name below is shown with the path that reaches it. Anything still spelled sql.mysql.statement.* needs import sql.mysql.statement.

A statement compiled once on the server and run many times.

Preparing sends the statement, and the server answers with the types it will bind and the columns it will return. Every execution after that sends only the values, in the binary encoding, which is both smaller than the text one and free of any question of quoting.

Classes

MySqlStatement

class sql.mysql.MySqlStatement < DriverStatement

A prepared statement.

  • printable — has a @to_string(), so echo and print() show something useful

Constructor

sql.mysql.MySqlStatement(connection, prepared, sql)

Parameters

  • connection (MySqlConnection)
  • prepared (dict) — What the server said when it compiled the statement.
  • sql (string)

MySqlStatement.id()

sql.mysql.MySqlStatement.id() -> number

The statement’s id on the server.

Returns number

MySqlStatement.sql()

sql.mysql.MySqlStatement.sql() -> string

The statement as it was compiled.

Returns string

MySqlStatement.raw_columns()

sql.mysql.MySqlStatement.raw_columns() -> list[dict]

The columns as the server described them, with everything it said about each rather than the two fields the contract asks for.

Returns list[dict]

MySqlStatement.columns()

sql.mysql.MySqlStatement.columns()

MySqlStatement.parameter_count()

sql.mysql.MySqlStatement.parameter_count()

MySqlStatement.execute()

sql.mysql.MySqlStatement.execute(values: list)

MySqlStatement.select()

sql.mysql.MySqlStatement.select(values: list)

MySqlStatement.open_cursor()

sql.mysql.MySqlStatement.open_cursor(values: list, options: dict)

MySqlStatement.close()

sql.mysql.MySqlStatement.close()

Releases the statement on the server. Safe to call more than once.

MySqlStatement.is_closed()

sql.mysql.MySqlStatement.is_closed() -> bool

Whether this statement has been released.

Returns bool

MySqlStatement.to_string()

sql.mysql.MySqlStatement.to_string()

2026, Richard Ore and Zuri contributors