Skip to main content
`Ctrl`+`K`

# Query

class beets.dbcore.query.Query

  Bases: `ABC`

  An abstract class representing a query into the database.

  __init__()

  Public methods summary

  `clause`() | Generate an SQLite expression implementing the query.
  `match`(obj) | Check whether this query matches a given Model.

  Methods definition

  property field_names: set[str]

    Return a set with field names that this query operates on.

  abstractmethod clause() → tuple[str | None, Sequence[Any]]

    Generate an SQLite expression implementing the query.

    Return (clause, subvals) where clause is a valid sqlite WHERE clause implementing the query and subvals is a list of items to be substituted for ?s in the clause.

    The default implementation returns None, falling back to a slow query using match().

  abstractmethod match(obj: Model) → bool

    Check whether this query matches a given Model. Can be used to perform queries on arbitrary sets of Model.