- class CockroachDBContainer(image: str = 'cockroachdb/cockroach:v24.1.1', username: str | None = None, password: str | None = None, dbname: str | None = None, dialect='cockroachdb+psycopg2', **kwargs)ΒΆ
CockroachDB database container.
Example
The example will spin up a CockroachDB database to which you can connect with the credentials passed in the constructor. Alternatively, you may use the
get_connection_url()method which returns a sqlalchemy-compatible url in formatdialect+driver://username:password@host:port/database.>>> import sqlalchemy >>> from testcontainers.community.cockroachdb import CockroachDBContainer >>> with CockroachDBContainer('cockroachdb/cockroach:v24.1.1') as crdb: ... engine = sqlalchemy.create_engine(crdb.get_connection_url()) ... with engine.begin() as connection: ... result = connection.execute(sqlalchemy.text("select version()")) ... version, = result.fetchone()