<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;"><div><div>I have no experience with MS SQL, only with PostgreSQL via psycopg2, but the idea is:</div>
<div><br></div><div>you want to execute many statements, probably in a blocking fashion: runInteraction()</div><div>you want to execute just one statement: runQuery()/runOperation()</div><div><br></div><div>AFAIK the latter one will do a commit for you if it is needed.</div>
<div><br></div><div>Anyway, for PostgreSQL I can specify isolation level I need.</div></div></div><br>_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com" target="_blank">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</blockquote><div><br>thnx to all. I used runOperation with the INSERTs and it was solved (or i think that was the cause).<br><br>The part of code with the problem was:<br><br><span style="font-family: courier new,monospace;">-----------------</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">from twisted.enterprise import adbapi</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">import pymssql</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">class DBAccess:</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> def __init__(self):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> # SQL-Server</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> myhost = "64.x.x.x:4000"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> mydatabase = "db"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> myuser = "user"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> mypassword = "password"</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> try:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.dbpool = adbapi.ConnectionPool("pymssql"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> , host=myhost</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> , user=myuser</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> , password=mypassword</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> , database=mydatabase</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> , cp_noisy=False)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> print("db connection pool created")</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> except Exception as e:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> print("error starting the ConnectionPool")</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> print(e)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> def insertDATA(self</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> , serialNumber</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> , customerAccount</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> , dateAndTime</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> , camcount</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> , fpv</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> , reff</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> , restOfFrame</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> sql = ''.join( </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> [ </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> "INSERT INTO fts_data VALUES ("</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> , "'" , serialNumber , "'"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> , "," , "'" , customerAccount , "'"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> , "," , "'" , dateAndTime , "'"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> , "," , camcount</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> , "," , fpv</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> , "," , "'" , reff , "'"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> , "," , "'" , restOfFrame , "'"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> , ") "</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ] )</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> #print(sql)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> try:</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> deferred = self.dbpool.runOperation(sql)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> #print("DATA sent")</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> except Exception as e:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> print("error in insertDATA")</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> print(e)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> return</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return deferred</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">------------------</span><br><br>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.<br>
<br>Since the program is written using Twisted, if anyone likes to step over, contact me directly and i'll provide details. <br></div><br>Pandelis Theodosiou<br></div><br><div style="display: inline;">
</div>