Dolt#

Integration with Dolt

Dolt is a MySQL-compatible database that provides Git-like versioning for your data.

Installation#

The fixture provides a running Dolt SQL service and validates availability with the container’s bundled tools. Since Dolt is MySQL-compatible, use the service attributes with the MySQL client, ORM, or application configuration you normally use.

Usage Example#

import mysql.connector
from pytest_databases.docker.dolt import DoltService

pytest_plugins = ["pytest_databases.docker.dolt"]

def test(dolt_service: DoltService) -> None:
    with mysql.connector.connect(
        host=dolt_service.host,
        port=dolt_service.port,
        user=dolt_service.user,
        database=dolt_service.db,
        password=dolt_service.password,
    ) as conn, conn.cursor() as cursor:
        cursor.execute("select 1 as is_available")
        resp = cursor.fetchone()
        assert resp is not None and resp[0] == 1

Available Fixtures#

  • dolt_service: A fixture that provides a Dolt service (latest).

  • dolt_user: The application user configured in the container.

  • dolt_password: The application user password configured in the container.

  • dolt_root_password: The root password configured in the container.

  • dolt_database: The initial database configured in the container.

Isolation Level#

By default, the dolt_service fixture uses database isolation, where each worker gets its own database on a shared server. You can change this to server isolation by overriding the xdist_dolt_isolation_level fixture.

@pytest.fixture(scope="session")
def xdist_dolt_isolation_level():
    return "server"

Service API#

Dolt container service fixtures.

class pytest_databases.docker.dolt.DoltService(container: docker.models.containers.Container, host: str, port: int, db: str, user: str, password: str)[source]#

Bases: ServiceContainer

Service handle for a running Dolt SQL container.

db: str#
user: str#
password: str#
__init__(container: docker.models.containers.Container, host: str, port: int, db: str, user: str, password: str) → None#
pytest_databases.docker.dolt.dolt_database() → str[source]#

Return the default Dolt database name.

pytest_databases.docker.dolt.dolt_image() → str[source]#

Return the Dolt container image.

pytest_databases.docker.dolt.dolt_password() → str[source]#

Return the Dolt database user password.

pytest_databases.docker.dolt.dolt_platform(request: FixtureRequest) → str | None[source]#

Return the target container platform for Dolt (None for native multi-arch).

pytest_databases.docker.dolt.dolt_root_password() → str[source]#

Return the Dolt root password.

pytest_databases.docker.dolt.dolt_service(docker_service: DockerService, xdist_dolt_isolation_level: XdistIsolationLevel, dolt_image: str, dolt_platform: str | None, dolt_user: str, dolt_password: str, dolt_root_password: str, dolt_database: str) → Generator[DoltService, None, None][source]#

Provide a running Dolt SQL container service.

Yields:

Active DoltService instance.

pytest_databases.docker.dolt.dolt_user() → str[source]#

Return the Dolt database user.

pytest_databases.docker.dolt.platform() → str[source]#

Return the legacy linux/x86_64 platform string.

Deprecated since version 0.20.0: Use dolt_platform instead. platform will be removed in v1.0.0.

pytest_databases.docker.dolt.provide_dolt_service(docker_service: DockerService, image: str, name: str, isolation_level: XdistIsolationLevel, platform: str | None, user: str, password: str, root_password: str, database: str) → Generator[DoltService, None, None][source]#

Start and manage a Dolt SQL server container service.

Yields:

Active DoltService instance.

Raises:

RuntimeError – If database initialization SQL fails across retries.

pytest_databases.docker.dolt.xdist_dolt_isolation_level() → Literal['database', 'server'][source]#

Return the pytest-xdist isolation level for Dolt.