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

Pantelis Theodosiou ypercube at gmail.com
Fri Sep 10 11:54:34 EDT 2010


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.
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>

thnx to all. I used runOperation with the INSERTs and it was solved (or i
think that was the cause).

The part of code with the problem was:

-----------------
from twisted.enterprise import adbapi
import pymssql


class DBAccess:

    def __init__(self):
        # SQL-Server
        myhost = "64.x.x.x:4000"
        mydatabase = "db"
        myuser = "user"
        mypassword = "password"

        try:
            self.dbpool = adbapi.ConnectionPool("pymssql"
                                    , host=myhost
                                    , user=myuser
                                    , password=mypassword
                                    , database=mydatabase
                                    , cp_noisy=False)
            print("db connection pool created")
        except Exception as e:
            print("error starting the ConnectionPool")
            print(e)

    def insertDATA(self
            , serialNumber
            , customerAccount
            , dateAndTime
            , camcount
            , fpv
            , reff
            , restOfFrame
            ):
        sql = ''.join(
            [
             "INSERT INTO fts_data VALUES ("
                    ,  "'" , serialNumber , "'"
            , "," , "'" , customerAccount , "'"
            , "," , "'" , dateAndTime , "'"
            , "," , camcount
            , "," , fpv
            , "," , "'" , reff , "'"
            , "," , "'" , restOfFrame , "'"
            , ") "
            ] )
        #print(sql)
        try:
            deferred = self.dbpool.runOperation(sql)
            #print("DATA sent")
        except Exception as e:
            print("error in insertDATA")
            print(e)
            return
        return deferred
------------------

Anyway, I'm now stuck at other levels, and I'm kind of out of ideas and the
customer wants (or has to) finish the whole project in a  very, very short
notice. Like yesterday. And my experience in Python and Twisted is not at
the level to solve problems and fix bugs quickly.

Since the program is written using Twisted, if anyone likes to step over,
contact me directly and i'll provide details.

Pandelis Theodosiou
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20100910/d3e5035f/attachment-0001.htm 


More information about the Twisted-Python mailing list