MySQL Extensions

Peewee provides an alternate database implementation for using themysql-connector driver. Theimplementation can be found in playhouse.mysql_ext.

Example usage:

  1. from playhouse.mysql_ext import MySQLConnectorDatabase
  2.  
  3. # MySQL database implementation that utilizes mysql-connector driver.
  4. db = MySQLConnectorDatabase('my_database', host='1.2.3.4', user='mysql')

Additional MySQL-specific helpers:

  • class JSONField
  • Extends TextField and implements transparent JSON encoding anddecoding in Python.
  • Match(columns, expr[, modifier=None])

Parameters:

  • columns – a single Field or a tuple of multiple fields.
  • expr (str) – the full-text search expression.
  • modifier (str) – optional modifiers for the search, e.g. ‘in boolean mode’.

Helper class for constructing MySQL full-text search queries of the form:

  1. MATCH (columns, ...) AGAINST (expr[ modifier])