Aestate
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
aestate.opera.DBPool.steady_pg.SteadyPgConnection Class Reference
Collaboration diagram for aestate.opera.DBPool.steady_pg.SteadyPgConnection:
Collaboration graph

Public Member Functions

def __init__ (self, maxusage=None, setsession=None, closeable=True, *args, **kwargs)
 
def __enter__ (self)
 
def __exit__ (self, *exc)
 
def close (self)
 
def reopen (self)
 
def reset (self)
 
def begin (self, sql=None)
 
def end (self, sql=None)
 
def commit (self, sql=None)
 
def rollback (self, sql=None)
 
def __getattr__ (self, name)
 
def __del__ (self)
 

Static Public Attributes

 version = __version__
 

Private Member Functions

def _setsession (self)
 
def _close (self)
 
def _get_tough_method (self, method)
 

Private Attributes

 _con
 
 _closed
 
 _maxusage
 
 _setsession_sql
 
 _closeable
 
 _transaction
 
 _usage
 

Detailed Description

Class representing steady connections to a PostgreSQL database.

Underlying the connection is a classic PyGreSQL pg API database
connection which is reset if the connection is lost or used too often.
Thus the resulting connection is steadier ("tough and self-healing").

If you want the connection to be persistent in a threaded environment,
then you should not deal with this class directly, but use either the
PooledPg module or the PersistentPg module to get the connections.

Definition at line 90 of file steady_pg.py.

Constructor & Destructor Documentation

◆ __init__()

def aestate.opera.DBPool.steady_pg.SteadyPgConnection.__init__ (   self,
  maxusage = None,
  setsession = None,
  closeable = True,
args,
**  kwargs 
)
Create a "tough" PostgreSQL connection.

maxusage: maximum usage limit for the underlying PyGreSQL connection
    (number of uses, 0 or None means unlimited usage)
    When this limit is reached, the connection is automatically reset.
setsession: optional list of SQL commands that may serve to prepare
    the session, e.g. ["set datestyle to ...", "set time zone ..."]
closeable: if this is set to false, then closing the connection will
    be silently ignored, but by default the connection can be closed
args, kwargs: the parameters that shall be used to establish
    the PostgreSQL connections with PyGreSQL using pg.DB()

Definition at line 104 of file steady_pg.py.

◆ __del__()

def aestate.opera.DBPool.steady_pg.SteadyPgConnection.__del__ (   self)
Delete the steady connection.

Definition at line 325 of file steady_pg.py.

Here is the call graph for this function:

Member Function Documentation

◆ __enter__()

def aestate.opera.DBPool.steady_pg.SteadyPgConnection.__enter__ (   self)
Enter the runtime context. This will start a transaction.

Definition at line 136 of file steady_pg.py.

Here is the call graph for this function:

◆ __exit__()

def aestate.opera.DBPool.steady_pg.SteadyPgConnection.__exit__ (   self,
exc 
)
Exit the runtime context. This will end the transaction.

Definition at line 141 of file steady_pg.py.

Here is the call graph for this function:

◆ __getattr__()

def aestate.opera.DBPool.steady_pg.SteadyPgConnection.__getattr__ (   self,
  name 
)
Inherit the members of the standard connection class.

Some methods are made "tougher" than in the standard version.

Definition at line 311 of file steady_pg.py.

Here is the call graph for this function:

◆ _close()

def aestate.opera.DBPool.steady_pg.SteadyPgConnection._close (   self)
private
Close the tough connection.

You can always close a tough connection with this method
and it will not complain if you close it more than once.

Definition at line 154 of file steady_pg.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _get_tough_method()

def aestate.opera.DBPool.steady_pg.SteadyPgConnection._get_tough_method (   self,
  method 
)
private
Return a "tough" version of a connection class method.

The tough version checks whether the connection is bad (lost)
and automatically and transparently tries to reset the connection
if this is the case (for instance, the database has been restarted).

Definition at line 276 of file steady_pg.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _setsession()

def aestate.opera.DBPool.steady_pg.SteadyPgConnection._setsession (   self)
private
Execute the SQL commands for session preparation.

Definition at line 148 of file steady_pg.py.

Here is the caller graph for this function:

◆ begin()

def aestate.opera.DBPool.steady_pg.SteadyPgConnection.begin (   self,
  sql = None 
)
Begin a transaction.

Definition at line 223 of file steady_pg.py.

Here is the caller graph for this function:

◆ close()

def aestate.opera.DBPool.steady_pg.SteadyPgConnection.close (   self)
Close the tough connection.

You are allowed to close a tough connection by default
and it will not complain if you close it more than once.

You can disallow closing connections by setting
the closeable parameter to something false.  In this case,
closing tough connections will be silently ignored.

Definition at line 168 of file steady_pg.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ commit()

def aestate.opera.DBPool.steady_pg.SteadyPgConnection.commit (   self,
  sql = None 
)
Commit the current transaction.

Definition at line 250 of file steady_pg.py.

Here is the caller graph for this function:

◆ end()

def aestate.opera.DBPool.steady_pg.SteadyPgConnection.end (   self,
  sql = None 
)
Commit the current transaction.

Definition at line 237 of file steady_pg.py.

◆ reopen()

def aestate.opera.DBPool.steady_pg.SteadyPgConnection.reopen (   self)
Reopen the tough connection.

It will not complain if the connection cannot be reopened.

Definition at line 183 of file steady_pg.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

def aestate.opera.DBPool.steady_pg.SteadyPgConnection.reset (   self)
Reset the tough connection.

If a reset is not possible, tries to reopen the connection.
It will not complain if the connection is already closed.

Definition at line 203 of file steady_pg.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rollback()

def aestate.opera.DBPool.steady_pg.SteadyPgConnection.rollback (   self,
  sql = None 
)
Rollback the current transaction.

Definition at line 263 of file steady_pg.py.

Here is the caller graph for this function:

Member Data Documentation

◆ _closeable

aestate.opera.DBPool.steady_pg.SteadyPgConnection._closeable
private

Definition at line 127 of file steady_pg.py.

◆ _closed

aestate.opera.DBPool.steady_pg.SteadyPgConnection._closed
private

Definition at line 119 of file steady_pg.py.

◆ _con

aestate.opera.DBPool.steady_pg.SteadyPgConnection._con
private

Definition at line 118 of file steady_pg.py.

◆ _maxusage

aestate.opera.DBPool.steady_pg.SteadyPgConnection._maxusage
private

Definition at line 125 of file steady_pg.py.

◆ _setsession_sql

aestate.opera.DBPool.steady_pg.SteadyPgConnection._setsession_sql
private

Definition at line 126 of file steady_pg.py.

◆ _transaction

aestate.opera.DBPool.steady_pg.SteadyPgConnection._transaction
private

Definition at line 129 of file steady_pg.py.

◆ _usage

aestate.opera.DBPool.steady_pg.SteadyPgConnection._usage
private

Definition at line 132 of file steady_pg.py.

◆ version

aestate.opera.DBPool.steady_pg.SteadyPgConnection.version = __version__
static

Definition at line 102 of file steady_pg.py.


The documentation for this class was generated from the following file: