Classes, methods and stuff.
Asynchronous conntion pool object. All its methods are asynchronous unless stated otherwide in method description.
Parameters: |
|
---|
Raised when Pool can not connect to database server
Call a stored database procedure with the given name.
See momoko.Connection.callproc() for documentation about the parameters.
Close the connection pool.
NOTE: This is a synchronous method.
Returns future that resolves to this Pool object.
If some connection failed to connect and self.raise_connect_errors is true, raises momoko.PartiallyConnectedError().
Prepare and execute a database operation (query or command).
See momoko.Connection.execute() for documentation about the parameters.
Acquire connection from the pool.
You can then use this connection for subsequent queries. Just use connection.execute instead of Pool.execute.
Make sure to return connection to the pool by calling momoko.Pool.putconn(), otherwise the connection will remain forever busy and you’ll starve your pool.
Returns a future that resolves to the acquired connection object.
Parameters: | ping (boolean) – Whether to ping the connection before returning it by executing momoko.Connection.ping(). |
---|
Context manager that automatically returns connection to the pool. You can use it instead of momoko.Pool.putconn():
connection = yield self.db.getconn()
with self.db.manage(connection):
cursor = yield connection.execute("BEGIN")
...
Return a query string after arguments binding.
NOTE: This is NOT a synchronous method (contary to momoko.Connection.mogrify) - it asynchronously waits for available connection. For performance reasons, its better to create dedicated momoko.Connection() object and use it directly for mogrification, this operation does not imply any real operation on the database server.
See momoko.Connection.mogrify() for documentation about the parameters.
Make sure this connection is alive by executing SELECT 1 statement - i.e. roundtrip to the database.
See momoko.Connection.ping() for documentation about the parameters.
Return busy connection back to the pool.
NOTE: This is a synchronous method.
Parameters: | connection (Connection) – Connection object previously returned by momoko.Pool.getconn(). |
---|
Register adapter and typecaster for dict-hstore conversions.
See momoko.Connection.register_hstore() for documentation about the parameters. This method has no globally parameter, because it already registers hstore to all the connections in the pool.
Create and register typecasters converting json type to Python objects.
See momoko.Connection.register_json() for documentation about the parameters. This method has no globally parameter, because it already registers json to all the connections in the pool.
Run a sequence of SQL queries in a database transaction.
See momoko.Connection.transaction() for documentation about the parameters.
Asynchronous connection object. All its methods are asynchronous unless stated otherwide in method description.
Parameters: |
|
---|
Call a stored database procedure with the given name.
The sequence of parameters must contain one entry for each argument that the procedure expects. The result of the call is returned as modified copy of the input sequence. Input parameters are left untouched, output and input/output parameters replaced with possibly new values.
The procedure may also provide a result set as output. This must then be made available through the standard fetch*() methods.
Parameters: |
|
---|
Returns future that resolves to cursor object containing result.
Closes the connection.
NOTE: This is a synchronous method.
Indicates whether the connection is closed or not.
Initiate asynchronous connect. Returns future that resolves to this connection object.
Prepare and execute a database operation (query or command).
Parameters: |
|
---|
Returns future that resolves to cursor object containing result.
Return a query string after arguments binding.
The string returned is exactly the one that would be sent to the database running the execute() method or similar.
NOTE: This is a synchronous method.
Parameters: |
|
---|
Make sure this connection is alive by executing SELECT 1 statement - i.e. roundtrip to the database.
Returns future. If it resolves sucessfully - the connection is alive (or dead otherwise).
Register adapter and typecaster for dict-hstore conversions.
More information on the hstore datatype can be found on the Psycopg2 documentation.
Parameters: |
|
---|
Returns future that resolves to None.
Create and register typecasters converting json type to Python objects.
More information on the json datatype can be found on the Psycopg2 documentation.
Parameters: |
|
---|
Returns future that resolves to None.
Run a sequence of SQL queries in a database transaction.
Parameters: |
|
---|
Returns future that resolves to list of cursors. Each cursor contains the result of the corresponding transaction statement.
Connection factory. See momoko.Connection() for documentation about the parameters.
Returns future that resolves to momoko.Connection() object or raises exception.
Raised when something goes wrong in the connection pool.
Raised when momoko.Pool() can not initialize all of the requested connections.