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

Yaroslav Fedevych jaroslaw.fedewicz at gmail.com
Fri Sep 10 07:51:14 EDT 2010

On Sep 10, 2010, at 5:17 AM, Pantelis Theodosiou wrote:

> 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

I have no experience with MS SQL, only with PostgreSQL via psycopg2, but the idea is:

you want to execute many statements, probably in a blocking fashion: runInteraction()
you want to execute just one statement: runQuery()/runOperation()

AFAIK the latter one will do a commit for you if it is needed.

Anyway, for PostgreSQL I can specify isolation level I need.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20100910/a0ffbeec/attachment.htm 

More information about the Twisted-Python mailing list