Python Connector for xBase

Connection pool class - Python Connector for xBase

Connection pool class

The connection_pool class is used to manage the connection pooling mechanism. This class provides properties for enabling and configuring pooling.

Properties

enabled

Enables connection pooling.

Syntax

enabled = False | True

Remarks

Set enabled to True to enable connection pooling. The default value is False.

max_size

The maximum number of connections allowed in the pool

Syntax

max_size = int
max_size[pool_id: int] = int

Remarks

When the maximum number of connections in the pool is reached, new database connections will be destroyed instead of released back into the pool after you close them. The default value of max_size is 100.
If no pool ID (pool_id) is specified, the maximum number of connections is set for the default connection pool. If the pool ID is specified, the maximum number of connections is set for the pool with the given ID.

min_size

The minimum number of connections maintained in the pool

Syntax

min_size = int
min_size[pool_id: int] = int

Remarks

Set this property to a non-zero value to prevent removing all connections from the pool after they have been idle for a long time. The default value of min_size is 0.
If no pool ID (pool_id) is specified, the minimum number of connections is set for the default connection pool. If the pool ID is specified, the minimum number of connections is set for the pool with the given ID.

lifetime

The maximum time (in milliseconds) during which a database connection will be kept in the connection pool

Syntax

lifetime = int
lifetime[pool_id: int] = int

Remarks

The creation time of a connection is compared with the current time, and the connection is destroyed if that timespan exceeds the lifetime. If lifetime is set to 0 (by default), the lifetime of a connection is infinite.
If no pool ID (pool_id) is specified, the connection lifetime is set for the default connection pool. If the pool ID is specified, the maximum number of connections is set for the pool with the given ID.

validate

Specifies whether to validate a connection when it's returned from the pool.

Syntax

validate[pool_id: int] = False | True

Remarks

If the value of validate is False, the pool will validate a connection only when it's added to the pool. If the value is True, the pool will validate a connection when it's added or drawn from the pool. The default value is False.
If no pool ID (pool_id) is specified, the validation rule is set for the default connection pool. If the pool ID is specified, the rule is set for the pool with the given ID.
© 2022-2024 Devart. All Rights Reserved. Request Support Python Connectors Forum Provide Feedback