Database

  • class Database(database[, thread_safe=True[, autorollback=False[, field_types=None[, operations=None[, autoconnect=True[, **kwargs]]]]]])

Parameters:

  • database (str) – Database name or filename for SQLite (or None todefer initialization, in which caseyou must call Database.init(), specifying the database name).
  • thread_safe (bool) – Whether to store connection state in athread-local.
  • autorollback (bool) – Automatically rollback queries that fail whennot in an explicit transaction.
  • field_types (dict) – A mapping of additional field types to support.
  • operations (dict) – A mapping of additional operations to support.
  • autoconnect (bool) – Automatically connect to database if attempting toexecute a query on a closed database.
  • kwargs – Arbitrary keyword arguments that will be passed to thedatabase driver when a connection is created, for example password,host, etc.

The Database is responsible for:

  • Executing queries
  • Managing connections
  • Transactions
  • Introspection

Note

The database can be instantiated with None as the database name ifthe database is not known until run-time. In this way you can create adatabase instance and then configure it elsewhere when the settings areknown. This is called deferred* initialization.

Examples:

  1. # Sqlite database using WAL-mode and 32MB page-cache.
  2. db = SqliteDatabase('app.db', pragmas={
  3. 'journal_mode': 'wal',
  4. 'cache_size': -32 * 1000})
  5.  
  6. # Postgresql database on remote host.
  7. db = PostgresqlDatabase('my_app', user='postgres', host='10.1.0.3',
  8. password='secret')

Deferred initialization example:

  1. db = PostgresqlDatabase(None)
  2.  
  3. class BaseModel(Model):
  4. class Meta:
  5. database = db
  6.  
  7. # Read database connection info from env, for example:
  8. db_name = os.environ['DATABASE']
  9. db_host = os.environ['PGHOST']
  10.  
  11. # Initialize database.
  12. db.init(db_name, host=db_host, user='postgres')
  • param = '?'
  • String used as parameter placeholder in SQL queries.

  • quote = '"'

  • Type of quotation-mark to use to denote entities such as tables orcolumns.

  • init(database[, **kwargs])

Parameters:

  1. - **database** (_str_) Database name or filename for SQLite.
  2. - **kwargs** Arbitrary keyword arguments that will be passed to thedatabase driver when a connection is created, for example<code>password</code>, <code>host</code>, etc.

Initialize a deferred database. See Run-time database configurationfor more info.

  • enter()
  • The Database instance can be used as a context-manager, inwhich case a connection will be held open for the duration of thewrapped block.

Additionally, any SQL executed within the wrapped block will beexecuted in a transaction.

  • connection_context()
  • Create a context-manager that will hold open a connection for theduration of the wrapped block.

Example:

  1. def on_app_startup():
  2. # When app starts up, create the database tables, being sure
  3. # the connection is closed upon completion.
  4. with database.connection_context():
  5. database.create_tables(APP_MODELS)
  • connect([reuse_if_open=False])

Parameters:reuse_if_open (bool) – Do not raise an exception if a connection isalready opened.Returns:whether a new connection was opened.Return type:boolRaises:OperationalError if connection already open andreuse_if_open is not set to True.

Open a connection to the database.

  • close()

Returns:Whether a connection was closed. If the database was alreadyclosed, this returns False.Return type:bool

Close the connection to the database.

  • is_closed()

Returns:return True if database is closed, False if open.Return type:bool

  • connection()
  • Return the open connection. If a connection is not open, one will beopened. The connection will be whatever the underlying database-driveruses to encapsulate a database connection.

  • cursor([commit=None])

Parameters:commit – For internal use.

Return a cursor object on the current connection. If a connectionis not open, one will be opened. The cursor will be whatever theunderlying database-driver uses to encapsulate a database cursor.

  • executesql(_sql[, params=None[, commit=SENTINEL]])

Parameters:

  1. - **sql** (_str_) SQL string to execute.
  2. - **params** (_tuple_) Parameters for query.
  3. - **commit** Boolean flag to override the default commit logic.Returns:

cursor object.

Execute a SQL query and return a cursor over the results.

  • execute(query[, commit=SENTINEL[, **context_options]])

Parameters:

  1. - **query** A [<code>Query</code>](#Query) instance.
  2. - **commit** Boolean flag to override the default commit logic.
  3. - **context_options** Arbitrary options to pass to the SQL generator.Returns:

cursor object.

Execute a SQL query by compiling a Query instance and executing theresulting SQL.

  • lastinsert_id(_cursor[, query_type=None])

Parameters:cursor – cursor object.Returns:primary key of last-inserted row.

  • rowsaffected(_cursor)

Parameters:cursor – cursor object.Returns:number of rows modified by query.

  • in_transaction()

Returns:whether or not a transaction is currently open.Return type:bool

  • atomic()
  • Create a context-manager which runs any queries in the wrapped block ina transaction (or save-point if blocks are nested).

Calls to atomic() can be nested.

atomic() can also be used as a decorator.

Example code:

  1. with db.atomic() as txn:
  2. perform_operation()
  3.  
  4. with db.atomic() as nested_txn:
  5. perform_another_operation()

Transactions and save-points can be explicitly committed or rolled-backwithin the wrapped block. If this occurs, a new transaction orsavepoint is begun after the commit/rollback.

Example:

  1. with db.atomic() as txn:
  2. User.create(username='mickey')
  3. txn.commit() # Changes are saved and a new transaction begins.
  4.  
  5. User.create(username='huey')
  6. txn.rollback() # "huey" will not be saved.
  7.  
  8. User.create(username='zaizee')
  9.  
  10. # Print the usernames of all users.
  11. print [u.username for u in User.select()]
  12.  
  13. # Prints ["mickey", "zaizee"]
  • manual_commit()
  • Create a context-manager which disables all transaction management forthe duration of the wrapped block.

Example:

  1. with db.manual_commit():
  2. db.begin() # Begin transaction explicitly.
  3. try:
  4. user.delete_instance(recursive=True)
  5. except:
  6. db.rollback() # Rollback -- an error occurred.
  7. raise
  8. else:
  9. try:
  10. db.commit() # Attempt to commit changes.
  11. except:
  12. db.rollback() # Error committing, rollback.
  13. raise

The above code is equivalent to the following:

  1. with db.atomic():
  2. user.delete_instance(recursive=True)
  • session_start()
  • Begin a new transaction (without using a context-manager or decorator).This method is useful if you intend to execute a sequence of operationsinside a transaction, but using a decorator or context-manager wouldnot be appropriate.

Note

It is strongly advised that you use the Database.atomic()method whenever possible for managing transactions/savepoints. Theatomic method correctly manages nesting, uses the appropriateconstruction (e.g., transaction-vs-savepoint), and always cleans upafter itself.

The session_start() method should only be usedif the sequence of operations does not easily lend itself towrapping using either a context-manager or decorator.

Warning

You must always call either session_commit()or session_rollback() after calling thesession_start method.

  • session_commit()
  • Commit any changes made during a transaction begun withsession_start().

  • session_rollback()

  • Roll back any changes made during a transaction begun withsession_start().

  • transaction()

  • Create a context-manager that runs all queries in the wrapped block ina transaction.

Warning

Calls to transaction cannot be nested. Only the top-most callwill take effect. Rolling-back or committing a nested transactioncontext-manager has undefined behavior.

  • savepoint()
  • Create a context-manager that runs all queries in the wrapped block ina savepoint. Savepoints can be nested arbitrarily.

Warning

Calls to savepoint must occur inside of a transaction.

  • begin()
  • Begin a transaction when using manual-commit mode.

Note

This method should only be used in conjunction with themanual_commit() context manager.

  • commit()
  • Manually commit the currently-active transaction.

Note

This method should only be used in conjunction with themanual_commit() context manager.

  • rollback()
  • Manually roll-back the currently-active transaction.

Note

This method should only be used in conjunction with themanual_commit() context manager.

  • batchcommit(_it, n)

Parameters:

  1. - **it** (_iterable_) an iterable whose items will be yielded.
  2. - **n** (_int_) commit every _n_ items.Returns:

an equivalent iterable to the one provided, with the additionthat groups of n items will be yielded in a transaction.

The purpose of this method is to simplify batching large operations,such as inserts, updates, etc. You pass in an iterable and the numberof items-per-batch, and the items will be returned by an equivalentiterator that wraps each batch in a transaction.

Example:

  1. # Some list or iterable containing data to insert.
  2. row_data = [{'username': 'u1'}, {'username': 'u2'}, ...]
  3.  
  4. # Insert all data, committing every 100 rows. If, for example,
  5. # there are 789 items in the list, then there will be a total of
  6. # 8 transactions (7x100 and 1x89).
  7. for row in db.batch_commit(row_data, 100):
  8. User.create(**row)

An alternative that may be more efficient is to batch the data into amulti-value INSERT statement (for example, usingModel.insert_many()):

  1. with db.atomic():
  2. for idx in range(0, len(row_data), 100):
  3. # Insert 100 rows at a time.
  4. rows = row_data[idx:idx + 100]
  5. User.insert_many(rows).execute()
  • tableexists(_table[, schema=None])

Parameters:

  1. - **table** (_str_) Table name.
  2. - **schema** (_str_) Schema name (optional).Returns:

bool indicating whether table exists.

  • gettables([_schema=None])

Parameters:schema (str) – Schema name (optional).Returns:a list of table names in the database.

  • getindexes(_table[, schema=None])

Parameters:

  1. - **table** (_str_) Table name.
  2. - **schema** (_str_) Schema name (optional).

Return a list of IndexMetadata tuples.

Example:

  1. print(db.get_indexes('entry'))
  2. [IndexMetadata(
  3. name='entry_public_list',
  4. sql='CREATE INDEX "entry_public_list" ...',
  5. columns=['timestamp'],
  6. unique=False,
  7. table='entry'),
  8. IndexMetadata(
  9. name='entry_slug',
  10. sql='CREATE UNIQUE INDEX "entry_slug" ON "entry" ("slug")',
  11. columns=['slug'],
  12. unique=True,
  13. table='entry')]
  • getcolumns(_table[, schema=None])

Parameters:

  1. - **table** (_str_) Table name.
  2. - **schema** (_str_) Schema name (optional).

Return a list of ColumnMetadata tuples.

Example:

  1. print(db.get_columns('entry'))
  2. [ColumnMetadata(
  3. name='id',
  4. data_type='INTEGER',
  5. null=False,
  6. primary_key=True,
  7. table='entry'),
  8. ColumnMetadata(
  9. name='title',
  10. data_type='TEXT',
  11. null=False,
  12. primary_key=False,
  13. table='entry'),
  14. ...]
  • getprimary_keys(_table[, schema=None])

Parameters:

  1. - **table** (_str_) Table name.
  2. - **schema** (_str_) Schema name (optional).

Return a list of column names that comprise the primary key.

Example:

  1. print(db.get_primary_keys('entry'))
  2. ['id']
  • getforeign_keys(_table[, schema=None])

Parameters:

  1. - **table** (_str_) Table name.
  2. - **schema** (_str_) Schema name (optional).

Return a list of ForeignKeyMetadata tuples for keys presenton the table.

Example:

  1. print(db.get_foreign_keys('entrytag'))
  2. [ForeignKeyMetadata(
  3. column='entry_id',
  4. dest_table='entry',
  5. dest_column='id',
  6. table='entrytag'),
  7. ...]
  • getviews([_schema=None])

Parameters:schema (str) – Schema name (optional).

Return a list of ViewMetadata tuples for VIEWs present inthe database.

Example:

  1. print(db.get_views())
  2. [ViewMetadata(
  3. name='entries_public',
  4. sql='CREATE VIEW entries_public AS SELECT ... '),
  5. ...]
  • sequenceexists(_seq)

Parameters:seq (str) – Name of sequence.Returns:Whether sequence exists.Return type:bool

  • createtables(_models[, **options])

Parameters:

  1. - **models** (_list_) A list of [<code>Model</code>](#Model) classes.
  2. - **options** Options to specify when calling[<code>Model.create_table()</code>](#Model.create_table).

Create tables, indexes and associated metadata for the given list ofmodels.

Dependencies are resolved so that tables are created in the appropriateorder.

  • droptables(_models[, **options])

Parameters:

  1. - **models** (_list_) A list of [<code>Model</code>](#Model) classes.
  2. - **kwargs** Options to specify when calling[<code>Model.drop_table()</code>](#Model.drop_table).

Drop tables, indexes and associated metadata for the given list ofmodels.

Dependencies are resolved so that tables are dropped in the appropriateorder.

  • bind(models[, bind_refs=True[, bind_backrefs=True]])

Parameters:

  1. - **models** (_list_) One or more [<code>Model</code>](#Model) classes to bind.
  2. - **bind_refs** (_bool_) Bind related models.
  3. - **bind_backrefs** (_bool_) Bind back-reference related models.

Bind the given list of models, and specified relations, to thedatabase.

  • bindctx(_models[, bind_refs=True[, bind_backrefs=True]])

Parameters:

  1. - **models** (_list_) List of models to bind to the database.
  2. - **bind_refs** (_bool_) Bind models that are referenced usingforeign-keys.
  3. - **bind_backrefs** (_bool_) Bind models that reference the given modelwith a foreign-key.

Create a context-manager that binds (associates) the given models withthe current database for the duration of the wrapped block.

Example:

  1. MODELS = (User, Account, Note)
  2.  
  3. # Bind the given models to the db for the duration of wrapped block.
  4. def use_test_database(fn):
  5. @wraps(fn)
  6. def inner(self):
  7. with test_db.bind_ctx(MODELS):
  8. test_db.create_tables(MODELS)
  9. try:
  10. fn(self)
  11. finally:
  12. test_db.drop_tables(MODELS)
  13. return inner
  14.  
  15.  
  16. class TestSomething(TestCase):
  17. @use_test_database
  18. def test_something(self):
  19. # ... models are bound to test database ...
  20. pass
  • extractdate(_date_part, date_field)

Parameters:

  1. - **date_part** (_str_) date part to extract, e.g. year’.
  2. - **date_field** ([_Node_](#Node)) a SQL node containing a date/time, for examplea [<code>DateTimeField</code>](#DateTimeField).Returns:

a SQL node representing a function call that will return theprovided date part.

Provides a compatible interface for extracting a portion of a datetime.

  • truncatedate(_date_part, date_field)

Parameters:

  1. - **date_part** (_str_) date part to truncate to, e.g. day’.
  2. - **date_field** ([_Node_](#Node)) a SQL node containing a date/time, for examplea [<code>DateTimeField</code>](#DateTimeField).Returns:

a SQL node representing a function call that will return thetruncated date part.

Provides a compatible interface for truncating a datetime to the givenresolution.

  • random()

Returns:a SQL node representing a function call that returns a randomvalue.

A compatible interface for calling the appropriate random numbergeneration function provided by the database. For Postgres and Sqlite,this is equivalent to fn.random(), for MySQL fn.rand().

  • class SqliteDatabase(database[, pragmas=None[, timeout=5[, **kwargs]]])

Parameters:

  • pragmas – Either a dictionary or a list of 2-tuples containingpragma key and value to set every time a connection is opened.
  • timeout – Set the busy-timeout on the SQLite driver (in seconds).

Sqlite database implementation. SqliteDatabase that providessome advanced features only offered by Sqlite.

  • Register custom aggregates, collations and functions
  • Load C extensions
  • Advanced transactions (specify lock type)
  • For even more features, see SqliteExtDatabase.Example of initializing a database and configuring some PRAGMAs:
  1. db = SqliteDatabase('my_app.db', pragmas=(
  2. ('cache_size', -16000), # 16MB
  3. ('journal_mode', 'wal'), # Use write-ahead-log journal mode.
  4. ))
  5.  
  6. # Alternatively, pragmas can be specified using a dictionary.
  7. db = SqliteDatabase('my_app.db', pragmas={'journal_mode': 'wal'})
  • pragma(key[, value=SENTINEL[, permanent=False]])

Parameters:

  1. - **key** Setting name.
  2. - **value** New value for the setting (optional).
  3. - **permanent** Apply this pragma whenever a connection is opened.

Execute a PRAGMA query once on the active connection. If a value is notspecified, then the current value will be returned.

If permanent is specified, then the PRAGMA query will also beexecuted whenever a new connection is opened, ensuring it is alwaysin-effect.

Note

By default this only affects the current connection. If the PRAGMAbeing executed is not persistent, then you must specifypermanent=True to ensure the pragma is set on subsequentconnections.

  • cache_size
  • Get or set the cache_size pragma for the current connection.

  • foreign_keys

  • Get or set the foreign_keys pragma for the current connection.

  • journal_mode

  • Get or set the journal_mode pragma.

  • journal_size_limit

  • Get or set the journal_size_limit pragma.

  • mmap_size

  • Get or set the mmap_size pragma for the current connection.

  • page_size

  • Get or set the page_size pragma.

  • read_uncommitted

  • Get or set the read_uncommitted pragma for the current connection.

  • synchronous

  • Get or set the synchronous pragma for the current connection.

  • wal_autocheckpoint

  • Get or set the wal_autocheckpoint pragma for the current connection.

  • timeout

  • Get or set the busy timeout (seconds).

  • registeraggregate(_klass[, name=None[, num_params=-1]])

Parameters:

  1. - **klass** Class implementing aggregate API.
  2. - **name** (_str_) Aggregate function name (defaults to name of class).
  3. - **num_params** (_int_) Number of parameters the aggregate accepts, or-1 for any number.

Register a user-defined aggregate function.

The function will be registered each time a new connection is opened.Additionally, if a connection is already open, the aggregate will beregistered with the open connection.

  • aggregate([name=None[, num_params=-1]])

Parameters:

  1. - **name** (_str_) Name of the aggregate (defaults to class name).
  2. - **num_params** (_int_) Number of parameters the aggregate accepts,or -1 for any number.

Class decorator to register a user-defined aggregate function.

Example:

  1. @db.aggregate('md5')class MD5(object): def initialize(self): self.md5 = hashlib.md5()

  2. def step(self, value):
  3.     self.md5.update(value)
  4. def finalize(self):
  5.     return self.md5.hexdigest()
  6. @db.aggregate()class Product(object): '''Like SUM() except calculates cumulative product.''' def init(self): self.product = 1

  7. def step(self, value):
  8.     self.product *= value
  9. def finalize(self):
  10.     return self.product

  • registercollation(_fn[, name=None])

Parameters:

  1. - **fn** The collation function.
  2. - **name** (_str_) Name of collation (defaults to function name)

Register a user-defined collation. The collation will be registeredeach time a new connection is opened. Additionally, if a connection isalready open, the collation will be registered with the openconnection.

  • collation([name=None])

Parameters:name (str) – Name of collation (defaults to function name)

Decorator to register a user-defined collation.

Example:

  1. @db.collation('reverse')def collate_reverse(s1, s2): return -cmp(s1, s2)

  2. Usage:

    Book.select().order_by(collate_reverse.collation(Book.title))

  3. Equivalent:

    Book.select().order_by(Book.title.asc(collation='reverse'))

As you might have noticed, the original collate_reverse functionhas a special attribute called collation attached to it. Thisextra attribute provides a shorthand way to generate the SQL necessaryto use our custom collation.

  • registerfunction(_fn[, name=None[, num_params=-1]])

Parameters:

  1. - **fn** The user-defined scalar function.
  2. - **name** (_str_) Name of function (defaults to function name)
  3. - **num_params** (_int_) Number of arguments the function accepts, or-1 for any number.

Register a user-defined scalar function. The function will beregistered each time a new connection is opened. Additionally, if aconnection is already open, the function will be registered with theopen connection.

  • func([name=None[, num_params=-1]])

Parameters:

  1. - **name** (_str_) Name of the function (defaults to function name).
  2. - **num_params** (_int_) Number of parameters the function accepts,or -1 for any number.

Decorator to register a user-defined scalar function.

Example:

  1. @db.func('title_case')def title_case(s): return s.title() if s else ''

  2. Usage:

    title_case_books = Book.select(fn.title_case(Book.title))

  • registerwindow_function(_klass[, name=None[, num_params=-1]])

Parameters:

  1. - **klass** Class implementing window function API.
  2. - **name** (_str_) Window function name (defaults to name of class).
  3. - **num_params** (_int_) Number of parameters the function accepts, or-1 for any number.

Register a user-defined window function.

Attention

This feature requires SQLite >= 3.25.0 andpysqlite3 >= 0.2.0.

The window function will be registered each time a new connection isopened. Additionally, if a connection is already open, the windowfunction will be registered with the open connection.

  • windowfunction([_name=None[, num_params=-1]])

Parameters:

  1. - **name** (_str_) Name of the window function (defaults to class name).
  2. - **num_params** (_int_) Number of parameters the function accepts, or -1for any number.

Class decorator to register a user-defined window function. Windowfunctions must define the following methods:

  1. - <code>step(&lt;params&gt;)</code> - receive values from a row and update state.
  2. - <code>inverse(&lt;params&gt;)</code> - inverse of <code>step()</code> for the given values.
  3. - <code>value()</code> - return the current value of the window function.
  4. - <code>finalize()</code> - return the final value of the window function.

Example:

  1. @db.windowfunction('mysum')class MySum(object): def __init(self): self._value = 0

  2. def step(self, value):
  3.     self._value += value
  4. def inverse(self, value):
  5.     self._value -= value
  6. def value(self):
  7.     return self._value
  8. def finalize(self):
  9.     return self._value

  • tablefunction([_name=None])
  • Class-decorator for registering a TableFunction. Tablefunctions are user-defined functions that, rather than returning asingle, scalar value, can return any number of rows of tabular data.

Example:

  1. from playhouse.sqlite_ext import TableFunction
  2.  
  3. @db.table_function('series')
  4. class Series(TableFunction):
  5. columns = ['value']
  6. params = ['start', 'stop', 'step']
  7.  
  8. def initialize(self, start=0, stop=None, step=1):
  9. """
  10. Table-functions declare an initialize() method, which is
  11. called with whatever arguments the user has called the
  12. function with.
  13. """
  14. self.start = self.current = start
  15. self.stop = stop or float('Inf')
  16. self.step = step
  17.  
  18. def iterate(self, idx):
  19. """
  20. Iterate is called repeatedly by the SQLite database engine
  21. until the required number of rows has been read **or** the
  22. function raises a `StopIteration` signalling no more rows
  23. are available.
  24. """
  25. if self.current > self.stop:
  26. raise StopIteration
  27.  
  28. ret, self.current = self.current, self.current + self.step
  29. return (ret,)
  30.  
  31. # Usage:
  32. cursor = db.execute_sql('SELECT * FROM series(?, ?, ?)', (0, 5, 2))
  33. for value, in cursor:
  34. print(value)
  35.  
  36. # Prints:
  37. # 0
  38. # 2
  39. # 4
  • unregisteraggregate(_name)

Parameters:name – Name of the user-defined aggregate function.

Unregister the user-defined aggregate function.

  • unregistercollation(_name)

Parameters:name – Name of the user-defined collation.

Unregister the user-defined collation.

  • unregisterfunction(_name)

Parameters:name – Name of the user-defined scalar function.

Unregister the user-defined scalar function.

  • unregistertable_function(_name)

Parameters:name – Name of the user-defined table function.Returns:True or False, depending on whether the function was removed.

Unregister the user-defined scalar function.

  • loadextension(_extension_module)
  • Load the given C extension. If a connection is currently open in thecalling thread, then the extension will be loaded for that connectionas well as all subsequent connections.

For example, if you’ve compiled the closure table extension and wish touse it in your application, you might write:

  1. db = SqliteExtDatabase('my_app.db')
  2. db.load_extension('closure')
  • attach(filename, name)

Parameters:

  1. - **filename** (_str_) Database to attach (or <code>:memory:</code> for in-memory)
  2. - **name** (_str_) Schema name for attached database.Returns:

boolean indicating success

Register another database file that will be attached to every databaseconnection. If the main database is currently connected, the newdatabase will be attached on the open connection.

Note

Databases that are attached using this method will be attachedevery time a database connection is opened.

  • detach(name)

Parameters:name (str) – Schema name for attached database.Returns:boolean indicating success

Unregister another database file that was attached previously with acall to attach(). If the main database iscurrently connected, the attached database will be detached from theopen connection.

  • transaction([lock_type=None])

Parameters:lock_type (str) – Locking strategy: DEFERRED, IMMEDIATE, EXCLUSIVE.

Create a transaction context-manager using the specified lockingstrategy (defaults to DEFERRED).

  • class PostgresqlDatabase(database[, register_unicode=True[, encoding=None[, isolation_level=None]]])
  • Postgresql database implementation.

Additional optional keyword-parameters:

Parameters:

  • register_unicode (bool) – Register unicode types.
  • encoding (str) – Database encoding.
  • isolation_level (int) – Isolation level constant, defined in thepsycopg2.extensions module.
  • settime_zone(_timezone)

Parameters:timezone (str) – timezone name, e.g. “US/Central”.Returns:no return value.

Set the timezone on the current connection. If no connection is open,then one will be opened.

  • class MySQLDatabase(database[, **kwargs])
  • MySQL database implementation.