Skip to main content
`Ctrl`+`K`

# Transaction

class beets.dbcore.db.Transaction(db: Database)

  Bases: `object`

  A context manager for safe, concurrent access to the database. All SQL commands should be executed through a transaction.

  __init__(db: Database)

  Public methods summary

  `mutate`(statement[, subvals]) | Execute an SQL statement with substitution values and return the row ID of the last affected row.
  `query`(statement[, subvals]) | Execute an SQL statement with substitution values and return a list of rows from the database.
  `script`(statements) | Execute a string containing multiple SQL statements.

  Methods definition

  mutate(statement: str, subvals: Sequence[SQLiteType] = ()) → Any

    Execute an SQL statement with substitution values and return the row ID of the last affected row.

  query(statement: str, subvals: Sequence[SQLiteType] = ()) → list[sqlite3.Row]

    Execute an SQL statement with substitution values and return a list of rows from the database.

  script(statements: str)

    Execute a string containing multiple SQL statements.