Forum: Ruby on Rails ActiveRecords question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
515898082d7e6c89dc58ef017d1c311e?d=identicon&s=25 Fish Man (fishman2001)
on 2006-02-23 12:33
I need to turn off and on the autocommit in MySql is there a method in
active records that allows me to do this?
or
is there a method which allows me to type in the pure mysql code
"set autocommit=0"

Thanks.
C64e63b70be7dfed8b0742540b8b27e5?d=identicon&s=25 Mark Reginald James (Guest)
on 2006-02-23 15:07
(Received via mailing list)
fish man wrote:
> I need to turn off and on the autocommit in MySql is there a method in
> active records that allows me to do this?
> or
> is there a method which allows me to type in the pure mysql code
> "set autocommit=0"

Model.connection.execute( 'SET AUTOCOMMIT=0' )

or

ActiveRecord::Base.connection.execute( 'SET AUTOCOMMIT=0' )

--
We develop, watch us RoR, in numbers too big to ignore.
Cac068c9c92719a59db960b2fa51719c?d=identicon&s=25 Iphan Iphan (iphan)
on 2006-05-31 19:36
Mark Reginald James wrote:
> fish man wrote:
>> I need to turn off and on the autocommit in MySql is there a method in
>> active records that allows me to do this?
>> or
>> is there a method which allows me to type in the pure mysql code
>> "set autocommit=0"
>
> Model.connection.execute( 'SET AUTOCOMMIT=0' )
>
> or
>
> ActiveRecord::Base.connection.execute( 'SET AUTOCOMMIT=0' )

this does not work for postgres. I get:

ERROR:  SET AUTOCOMMIT TO OFF is no longer supported

Has anyone managed to find the correct syntax?

I've also tried

ActiveRecord::Base.connection.begin_db_transaction

to set autocommit off at the topmost level, but it does not prevent
COMMIT statement to be issued on save().
This topic is locked and can not be replied to.