[Twisted-Python] Strange error: SQL-Server tries to rollback

Pantelis Theodosiou ypercube at gmail.com
Thu Sep 9 22:17:28 EDT 2010


I have a simple INSERT INTO statement sent to SQL-Server using pymssql
module.

I use the runOperation method to send the query and I get this strange
error. The data goes through OK and is written in the database but
SQL-Server tries to rollback.

Perhaps this is a pymssql problem. In the
http://code.google.com/p/pymssql/wiki/PymssqlExamples
page, they state:

import pymssql
conn = pymssql.connect(host='SQL01', user='user', password='password',
database='mydatabase')
cur = conn.cursor()
cur.execute('CREATE TABLE persons(id INT, name VARCHAR(100))')
cur.executemany("INSERT INTO persons VALUES(%d, %s)", \
    [ (1, 'John Doe'), (2, 'Jane Doe') ])
conn.commit()  # you must call commit() to persist your data if you
don't set autocommit to True


But how can I use the con.commit method with runOperation and runQuery that
I use in my application?

thank you,

Pandelis Theodosiou


Here is the error:

Traceback (most recent call last):
  File "/usr/lib/python2.6/threading.py", line 484, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/lib/python2.6/dist-packages/twisted/python/threadpool.py", line
210, in _worker
    result = context.call(ctx, function, *args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/twisted/python/context.py", line
59, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/lib/python2.6/dist-packages/twisted/python/context.py", line
37, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/usr/lib/python2.6/dist-packages/twisted/enterprise/adbapi.py", line
436, in _runInteraction
    conn.rollback()
  File "/usr/lib/python2.6/dist-packages/twisted/enterprise/adbapi.py", line
52, in rollback
    self._connection.rollback()
  File "/usr/lib/pymodules/python2.6/pymssql.py", line 496, in rollback
    raise OperationalError, "cannot roll back transaction: " + e[0]
pymssql.OperationalError: cannot roll back transaction: SQL Server message
3903, severity 16, state 1, line 1:
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION.
DB-Lib error message 3903, severity 16:
General SQL Server error: Check messages from the SQL Server
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20100910/fcb20e06/attachment-0001.htm 


More information about the Twisted-Python mailing list