# How do I make a direct SQL call (e.g. LOCK TABLES)?

**URL:** <https://www.ruby-forum.com/t/how-do-i-make-a-direct-sql-call-e-g-lock-tables/141105>\
**Category:** Rails\
**Created:** [June 22, 2008, 3:25am UTC](https://www.ruby-forum.com/t/how-do-i-make-a-direct-sql-call-e-g-lock-tables/141105 "2008-06-22T03:25:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [June 22, 2008, 3:25am UTC](https://www.ruby-forum.com/t/how-do-i-make-a-direct-sql-call-e-g-lock-tables/141105/1 "2008-06-22T03:25:57Z")

</div>

Hi,  
I’m stuck. I can’t quite see in Rails how to make a direct database  
call  
(e.g. LOCK TABLES…), and leverage the rails connection framework?

How do you do this? I see the “execute” command in  
ActiveRecord::ConnectionAdapters::DatabaseStatements  
doesn’t seem to work.

Thanks

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [June 22, 2008, 7:51am UTC](https://www.ruby-forum.com/t/how-do-i-make-a-direct-sql-call-e-g-lock-tables/141105/2 "2008-06-22T07:51:08Z")

</div>

You can call:

Mymodel.connection.execute(“LOCK TABLES…”)

with whatever SQL you need…

Brent

Greg H. wrote:

> Hi,  
> I’m stuck. I can’t quite see in Rails how to make a direct database  
> call  
> (e.g. LOCK TABLES…), and leverage the rails connection framework?
> 
> How do you do this? I see the “execute” command in  
> ActiveRecord::ConnectionAdapters::DatabaseStatements  
> doesn’t seem to work.
> 
> Thanks
