mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 17:06:33 +03:00
Exposed connection status.
This commit is contained in:
parent
53d10a3ddf
commit
8eb118c63f
|
@ -1,5 +1,8 @@
|
|||
2006-09-01 Federico Di Gregorio <fog@initd.org>
|
||||
|
||||
* psycopg/connection_type.c: added .status attribute to expose
|
||||
the internal status.
|
||||
|
||||
* psycopg/pqpath.c: applied patch from intgr (#117) to fix
|
||||
segfault on null queries.
|
||||
|
||||
|
|
|
@ -43,14 +43,24 @@ from _psycopg import string_types, binary_types, new_type, register_type
|
|||
from _psycopg import ISQLQuote
|
||||
|
||||
"""Isolation level values."""
|
||||
ISOLATION_LEVEL_AUTOCOMMIT = 0
|
||||
ISOLATION_LEVEL_AUTOCOMMIT = 0
|
||||
ISOLATION_LEVEL_READ_COMMITTED = 1
|
||||
ISOLATION_LEVEL_SERIALIZABLE = 2
|
||||
ISOLATION_LEVEL_SERIALIZABLE = 2
|
||||
|
||||
# PostgreSQL maps the the other standard values to already defined levels
|
||||
ISOLATION_LEVEL_REPEATABLE_READ = ISOLATION_LEVEL_SERIALIZABLE
|
||||
ISOLATION_LEVEL_READ_UNCOMMITTED = ISOLATION_LEVEL_READ_COMMITTED
|
||||
|
||||
"""Transaction status values."""
|
||||
STATUS_SETUP = 0
|
||||
STATUS_READY = 1
|
||||
STATUS_BEGIN = 2
|
||||
STATUS_SYNC = 3
|
||||
STATUS_ASYNC = 4
|
||||
|
||||
# This is a usefull mnemonic to check if the connection is in a transaction
|
||||
STATUS_IN_TRANSACTION = STATUS_BEGIN
|
||||
|
||||
|
||||
def register_adapter(typ, callable):
|
||||
"""Register 'callable' as an ISQLQuote adapter for type 'typ'."""
|
||||
|
|
|
@ -260,6 +260,9 @@ static struct PyMemberDef connectionObject_members[] = {
|
|||
{"notifies", T_OBJECT, offsetof(connectionObject, notifies), RO},
|
||||
{"dsn", T_STRING, offsetof(connectionObject, dsn), RO,
|
||||
"The current connection string."},
|
||||
{"status", T_LONG,
|
||||
offsetof(connectionObject, status), RO,
|
||||
"The current transaction status."},
|
||||
#endif
|
||||
{NULL}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user