pycroxe.connect#

pycroxe.connect(url: str | None = None, host: str = 'localhost', user: str = 'croxe-guest', connector: str = 'mariadb+mariadbconnector', database: str = 'CroXe', **engine_kwargs) CroXeConnection#

If used outside of a with statement, create and return an unopened pycroxe.CroXeConnection. The intended use is within a with statement, which returns instead an open pycroxe.CroXeConnection:

with connect() as conn:
    ...

Parameters#

urlstr, optional

SQLAlchemy connection URL. If None, the value of the CROXE_DB environment variable is used; if that is also unset, a URL will be constructed using the connector, user, host and database parameters. With default values, the constructed URL is:

mariadb+mariadbconnector://croxe-guest@localhost/CroXe
hoststr, optional

Name or IP address of the machine hosting the database (default: localhost). Ports can be selected by appending a colon, followed by the port number, to the host name or IP address:

hostname:portnumber
userstr, optional

Name of the loggin user (default: croxe-guest). Note that passwords can be used as well, by appending them with a leading colon to the username, though it is strongly discouraged since this method exposes the password:

username:password
connectorstr, optional

Combination of SQLAlchemy dialect and driver (default: mariadb+mariadbconnector).

databasestr, optional

Database to be used (default: CroXe).

engine_kwargsdict, optional

Extra keyword arguments forwarded verbatim to sqlalchemy.engine.create_engine() (e.g. pool_pre_ping=True).

Returns#

connpycroxe.CroXeConnection

An instance ready to be used, possibly as a context manager.