[Twisted-Python] adapi.Connection._runQuery always does rollback()
Eric C. Newton
ecn at metaslash.com
Sat Apr 26 10:12:08 MDT 2003
Sure, that's a theory. And, yay, verily, MySQL isn't known for it's
strict adherance to standards. However:
http://www.python.org/topics/database/DatabaseAPI-2.0.html#connection
Says
rollback()
This method is optional since not all databases provide
transaction support.[3]
And footnote 3 sayeth:
3 If the database does not support the functionality required by
the method, the interface should throw an exception in case the
method is used.
The preferred approach is to not implement the method and thus
have Python generate an AttributeError in case the method is
requested. This allows the programmer to check for database
capabilities using the standard hasattr() function.
For some dynamically configured interfaces it may not be
appropriate to require dynamically making the method
available. These interfaces should then raise a NotSupportedError
to indicate the non-ability to perform the roll back when the
method is invoked.
Further, a rollback trashes a whole transaction. The query could be
part of a larger transaction which includes update operations.
Granted, this is just silly in the async thread-pool, but that's why I
found it rather surprising.
-Eric
On Sun, Apr 27, 2003 at 12:07:22AM +1000, Andrew Bennetts wrote:
> On Sat, Apr 26, 2003 at 09:55:46AM -0400, Eric C. Newton wrote:
> > RedHat 9.0 on intel
> > Twisted 1.0.4
> >
> > In twisted.enterprise.adbapi we find this method of ConnectionPool:
>
> [snip -- runQuery always does a rollback]
>
> The theory here, I believe is that queries are meant to have no side-effects
> on the DB, so the rollback is done to guarantee this. If you *do* want to
> change the state of the DB, use runOperation.
>
> > PS. This buglet brought to you by MySQL which does not support rollback(),
> > and tells you with an exception.
>
> Then the database module you are using doesn't adhere to DB-API 2.0[1], which
> adbapi requires.
>
> -Andrew.
>
> [1] http://www.python.org/topics/database/DatabaseAPI-2.0.html
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
More information about the Twisted-Python
mailing list