singlestoredb.connection.Cursor.execute

abstract Cursor.execute(query: str, args: Sequence[Any] | Dict[str, Any] | Any | None = None) int

Execute a SQL statement.

Queries can use the format-style parameters (%s) when using a list of paramters or pyformat-style parameters (%(key)s) when using a dictionary of parameters.

Parameters:
  • query (str) – The SQL statement to execute

  • args (Sequence or dict, optional) – Parameters to substitute into the SQL code

Examples

>>> cur.execute('select * from mytable')
>>> cur.execute('select * from mytable where id < %s', [100])
>>> cur.execute('select * from mytable where id < %(max)s', dict(max=100))
Return type:

Number of rows affected