On Mar 7, 2008, at 12:48 AM, noelsplace wrote:

>
> I am trying to implement a generic REPLACE INTO as shown below.  The
> code works fine if REPLACE INTO is changed to INSERT INTO.  There
> really should not be any difference between REPLACE and INSERT if the
> table is empty to start with.  Also, the REPLACE command works fine
> when issued manually from a MySQL client.
>
> Using a packet sniffer, it looks as though SQLAlchemy is issuing a
> ROLLBACK command when REPLACE INTO is used -- which explains why the
> table never gets updated with the data.
>
> What is causing the ROLLBACK to get issued at the end of the REPLACE
> INTO statement?  Rollback doesn't appear to happen when INSERT INTO is
> used?

use at least version 0.4.3 of SQLAlchemy, and set the flag  
"autocommit=True" on your text() construct.   But this only applies to  
statements that are not wihtin an explicit transaction, and I can see  
you're trying to be explicit below....

>        trans = cls.table.engine.connect().begin()
>        cls.table.engine.connect().execute(statement2,datadct)
>        trans.commit()
>

so theres also a second issue here.  You're using two different  
connections above since you are calling connect() twice.  call  
connect() only once and execute the statement with the same Connection  
in which you retrieved the Transaction from.

- mike

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to