mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 17:06:33 +03:00
.get_transaction_status() implementation.
This commit is contained in:
parent
d6e232e2b9
commit
a779c8ef99
|
@ -1,3 +1,10 @@
|
|||
2007-04-25 Federico Di Gregorio <fog@initd.org>
|
||||
|
||||
* psycopg/connection_type.c: added support for a new method
|
||||
.get_transaction_status() that returns the backend transaction
|
||||
status as libpq knows. Also added some symbolic constants to
|
||||
psycopg.extensions module (TRANSACTION_STATUS_XXX).
|
||||
|
||||
2007-04-14 Federico Di Gregorio <fog@initd.org>
|
||||
|
||||
* psycopg/psycopg.h: fixed probable typo in definition of
|
||||
|
|
|
@ -51,8 +51,8 @@ ISOLATION_LEVEL_SERIALIZABLE = 2
|
|||
ISOLATION_LEVEL_REPEATABLE_READ = ISOLATION_LEVEL_SERIALIZABLE
|
||||
ISOLATION_LEVEL_READ_UNCOMMITTED = ISOLATION_LEVEL_READ_COMMITTED
|
||||
|
||||
"""Transaction status values."""
|
||||
STATUS_SETUP = 0
|
||||
"""psycopg connection status values."""
|
||||
STATUS_SETUP = 0
|
||||
STATUS_READY = 1
|
||||
STATUS_BEGIN = 2
|
||||
STATUS_SYNC = 3
|
||||
|
@ -61,6 +61,12 @@ STATUS_ASYNC = 4
|
|||
# This is a usefull mnemonic to check if the connection is in a transaction
|
||||
STATUS_IN_TRANSACTION = STATUS_BEGIN
|
||||
|
||||
"""Backend transaction status values."""
|
||||
TRANSACTION_STATUS_IDLE = 0
|
||||
TRANSACTION_STATUS_ACTIVE = 1
|
||||
TRANSACTION_STATUS_INTRANS = 2
|
||||
TRANSACTION_STATUS_INERROR = 3
|
||||
TRANSACTION_STATUS_UNKNOWN = 4
|
||||
|
||||
def register_adapter(typ, callable):
|
||||
"""Register 'callable' as an ISQLQuote adapter for type 'typ'."""
|
||||
|
|
|
@ -146,6 +146,7 @@ psyco_conn_rollback(connectionObject *self, PyObject *args)
|
|||
|
||||
|
||||
#ifdef PSYCOPG_EXTENSIONS
|
||||
|
||||
/* set_isolation_level method - switch connection isolation level */
|
||||
|
||||
#define psyco_conn_set_isolation_level_doc \
|
||||
|
@ -173,8 +174,6 @@ psyco_conn_set_isolation_level(connectionObject *self, PyObject *args)
|
|||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* set_isolation_level method - switch connection isolation level */
|
||||
|
||||
#define psyco_conn_set_client_encoding_doc \
|
||||
|
@ -210,6 +209,22 @@ psyco_conn_set_client_encoding(connectionObject *self, PyObject *args)
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* set_isolation_level method - switch connection isolation level */
|
||||
|
||||
#define psyco_conn_get_transaction_status_doc \
|
||||
"get_transaction_status() -- Get backend transaction status."
|
||||
|
||||
static PyObject *
|
||||
psyco_conn_get_transaction_status(connectionObject *self, PyObject *args)
|
||||
{
|
||||
EXC_IF_CONN_CLOSED(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
|
||||
return PyInt_FromLong((long)PQtransactionStatus(self->pgconn));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -232,6 +247,8 @@ static struct PyMethodDef connectionObject_methods[] = {
|
|||
METH_VARARGS, psyco_conn_set_isolation_level_doc},
|
||||
{"set_client_encoding", (PyCFunction)psyco_conn_set_client_encoding,
|
||||
METH_VARARGS, psyco_conn_set_client_encoding_doc},
|
||||
{"get_transaction_status", (PyCFunction)psyco_conn_get_transaction_status,
|
||||
METH_VARARGS, psyco_conn_get_transaction_status_doc},
|
||||
#endif
|
||||
{NULL}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user