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:
ServiceContainerService handle for a running Dolt SQL container.
- 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_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.platform() str[source]#
Return the legacy
linux/x86_64platform string.Deprecated since version 0.20.0: Use
dolt_platforminstead.platformwill 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.