Aestate
|
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 | |
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.
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.
def aestate.opera.DBPool.steady_pg.SteadyPgConnection.__del__ | ( | self | ) |
Delete the steady connection.
Definition at line 325 of file steady_pg.py.
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.
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.
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.
|
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.
|
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.
|
private |
Execute the SQL commands for session preparation.
Definition at line 148 of file steady_pg.py.
def aestate.opera.DBPool.steady_pg.SteadyPgConnection.begin | ( | self, | |
sql = None |
|||
) |
Begin a transaction.
Definition at line 223 of file steady_pg.py.
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.
def aestate.opera.DBPool.steady_pg.SteadyPgConnection.commit | ( | self, | |
sql = None |
|||
) |
Commit the current transaction.
Definition at line 250 of file steady_pg.py.
def aestate.opera.DBPool.steady_pg.SteadyPgConnection.end | ( | self, | |
sql = None |
|||
) |
Commit the current transaction.
Definition at line 237 of file steady_pg.py.
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.
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.
def aestate.opera.DBPool.steady_pg.SteadyPgConnection.rollback | ( | self, | |
sql = None |
|||
) |
Rollback the current transaction.
Definition at line 263 of file steady_pg.py.
|
private |
Definition at line 127 of file steady_pg.py.
|
private |
Definition at line 119 of file steady_pg.py.
|
private |
Definition at line 118 of file steady_pg.py.
|
private |
Definition at line 125 of file steady_pg.py.
|
private |
Definition at line 126 of file steady_pg.py.
|
private |
Definition at line 129 of file steady_pg.py.
|
private |
Definition at line 132 of file steady_pg.py.
|
static |
Definition at line 102 of file steady_pg.py.