Module sqltable.pool
A connection pooling object.
This allows for lots of tables to be opened with only as many connections as are needed to be created. Also, it provides for some level of fault tolerance: stale connections are automatically purged.
Functions
_pool.type (pool) | Return the type of database this pool connects to. |
_pool.get (pool) | Checkout a connection from the pool for use. |
_pool.put (pool, connection) | Return a connection to the pool. |
_pool.connections (pool) | Returns a count of the total number of connections this pool has open. |
_pool.outstanding (pool) | Returns a count of connections that exist, but are in use and not waiting in the pool. |
_pool.close (pool) | Shuts down the pool. |
_pool.reset (pool) | Resets a pool by closing all connections, then reconnecting with just one. |
_pool.setup_hook (pool, fcn) | Sets a 'setup hook' that will be called every time a new connection is opened. |
_pool.connect (params) | "Connect" to a database. |
Functions
- _pool.type (pool)
-
Return the type of database this pool connects to.
Parameters:
- pool Pool to checked
Returns:
-
Database type of pool
- _pool.get (pool)
-
Checkout a connection from the pool for use.
Parameters:
- pool Pool to retrieve connection from
Returns:
-
A usable LuaDBI connection
- _pool.put (pool, connection)
-
Return a connection to the pool.
Parameters:
- pool Pool receiving connection
- connection Connection to be returned
- _pool.connections (pool)
-
Returns a count of the total number of connections this
pool has open.
Parameters:
- pool Pool to check
Returns:
-
Total number of connections in pool
- _pool.outstanding (pool)
-
Returns a count of connections that exist, but are in use
and not waiting in the pool.
Parameters:
- pool Pool to check
Returns:
-
Number of outstanding connections in pool
- _pool.close (pool)
-
Shuts down the pool.
THIS EXPLODES BADLY if there are outstanding connections not yet returned. Stop all queries before calling it!
Parameters:
- pool Pool to close
- _pool.reset (pool)
-
Resets a pool by closing all connections, then reconnecting
with just one. This is handy if your program forks and/or you
want to recycle all file handles.
Parameters:
- pool Pool to reset
- _pool.setup_hook (pool, fcn)
-
Sets a 'setup hook' that will be called every time a new
connection is opened.
The pool will be reset once a hook is set, thus closing all open connections and reconnecting.
Parameters:
- pool this pool object
- fcn Setup hook to call
- _pool.connect (params)
-
"Connect" to a database. This opens the first connection to
a database to ensure the settings are correct, then returns
a pool object containing one connection.
Parameters:
- params