ActiveRecords question


#1

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.


#2

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.


#3

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().