Hello,

I just noticed the very same problem with PYODBC and SQL Server 2012. In my 
case it only failed silently some times and failing was somehow related to 
trigger execution time which in my case varies a bit. I was able to first 
get it to work with waiting for 1 second before commit. But there was 
easier solution which was to use 'set nocount on' before executing update 
statement. 

Br, Hr

maanantai 12. lokakuuta 2009 9.09.45 UTC+3 Nicol van der Merwe kirjoitti:
>
>
>
> On Sun, Oct 11, 2009 at 4:35 PM, Michael Bayer <mik...@zzzcomputing.com 
> <javascript:>> wrote:
>
>>
>>
>> On Oct 11, 2009, at 9:32 AM, Nicol van der Merwe wrote:
>>
>> > Hi All
>> >
>> > I am using sqlsoup and pyodbc to update a couple of rows in the
>> > database. On a number of tables in the database I have triggers that
>> > basically checks keeps a log of changes on certain columns in the
>> > table (inserts changes into another table). My problem is that I am
>> > unable to update values on tables that has this trigger. No error/
>> > warning is thrown, it just fails silently. When I disable the
>> > triggers the updates work fine. Also, if I run the update statement
>> > directly on the database it works as expected, whether it's run with
>> > or without the triggers.
>>
>> the main issue with your script is that the work you are doing with
>> "connection" and "trans" is meaningless versus the operation you are
>> performing on your objects.  SQLSoup uses the ORM so you need to be
>> using the Session to control transactional scope - this is documented
>> here:  http://www.sqlalchemy.org/docs/05/session.html .    I think for
>> SQLSoup itself its sufficient to say db.commit().
>>
>> beyond that, if there is truly a different behavior when the trigger
>> exists versus does not, the next meaningful test is to try your use
>> case with a raw pyODBC script.   At that point its likely an ODBC
>> related issue.
>>
>>
>>
>>
> Hi Michael 
>
> I did as you suggested and tried the session - and it didn't work. 
> According to the documentation, pyodbc is the preferred module for sql 
> server so up until now I had just tried that. As a last resort I tried 
> pymssql - and it worked(!). Even if I directly issue the updates using 
> pyodbc, it fails - whereas the same update succeeds with pymssql. Could 
> this mean that the issue lies with pyodbc?
>
> I am going to try and put together a test so prove that this is indeed a 
> bug and submit it to the pyodbc guys. Maybe I can even write a patch to fix 
> this. I need to investigate it a bit further though as I'm a bit pressed 
> for time and need my application just working for now.
>
> Thanks for your help though.
>
> Regards
> -- 
> Nicolaas
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to