# ActiveRecords question

**URL:** <https://www.ruby-forum.com/t/activerecords-question/72279>\
**Category:** Rails\
**Created:** [February 23, 2006, 12:33pm UTC](https://www.ruby-forum.com/t/activerecords-question/72279 "2006-02-23T12:33:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fishman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@fishman2001](https://www.ruby-forum.com/u/fishman2001)\
**Post date:** [February 23, 2006, 12:33pm UTC](https://www.ruby-forum.com/t/activerecords-question/72279/1 "2006-02-23T12:33:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![fishman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@fishman2001](https://www.ruby-forum.com/u/fishman2001)\
**Post date:** [February 23, 2006, 3:07pm UTC](https://www.ruby-forum.com/t/activerecords-question/72279/2 "2006-02-23T15:07:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![fishman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@fishman2001](https://www.ruby-forum.com/u/fishman2001)\
**Post date:** [May 31, 2006, 7:36pm UTC](https://www.ruby-forum.com/t/activerecords-question/72279/3 "2006-05-31T19:36:00Z")

</div>

Mark Reginald J. 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().
