'How to check "autocommit" value in ActiveRecord

My application is RoR and MySQL based. I would like to turn autocommit from ON to OFF and I know how to do it in MySQL. But do I need to stop and restart my Rails server to make sure this change takes effect in my application?

I would like to know if there is a way in ActiveRecord to check the value of "autocommit" in the MySQL database?

Thanks.



Solution 1:[1]

But do I need to stop and restart my Rails server to make sure this change takes effect in my application?

No, you don't have to, because that's a MySQL variable.

I would like to know if there is a way in ActiveRecord to check the value of "autocommit" in the MySQL database?

You can do:

ActiveRecord::Base.connection.exec_query('SELECT @@autocommit')

Solution 2:[2]

how to know it is locked or not for mysql

show variables like '%autocommit%';

how to change the status for autocommit in my sql

set autocommit = OFF/ON;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 failingtocode