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
withstatement, create and return an unopenedpycroxe.CroXeConnection. The intended use is within awithstatement, which returns instead an openpycroxe.CroXeConnection:with connect() as conn: ...
Parameters#
- urlstr, optional
SQLAlchemy connection URL. If
None, the value of theCROXE_DBenvironment variable is used; if that is also unset, a URL will be constructed using theconnector,user,hostanddatabaseparameters. 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#
- conn
pycroxe.CroXeConnection An instance ready to be used, possibly as a context manager.