# ActiveRecord::Base

**URL:** <https://www.ruby-forum.com/t/activerecord-base/162207>\
**Category:** Rails\
**Created:** [March 6, 2009, 7:26pm UTC](https://www.ruby-forum.com/t/activerecord-base/162207 "2009-03-06T19:26:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luboherko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/b782af/32.png) [@luboherko](https://www.ruby-forum.com/u/luboherko)\
**Post date:** [March 6, 2009, 7:26pm UTC](https://www.ruby-forum.com/t/activerecord-base/162207/1 "2009-03-06T19:26:47Z")

</div>

Why this doesn’t work?

ActiveRecord::Base.connection.execute("\d") ?

I use PostgreSQL server and this should be command to get list of all  
tables within a database. Is there a problem with privileges or PGSQL  
driver for rails doesn’t support it?

---

<div class="post-metadata">

**Author:** ![luboherko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/b782af/32.png) [@luboherko](https://www.ruby-forum.com/u/luboherko)\
**Post date:** [March 6, 2009, 7:35pm UTC](https://www.ruby-forum.com/t/activerecord-base/162207/2 "2009-03-06T19:35:26Z")

</div>

On 6 Mar 2009, at 18:26, Lubomir Herko wrote:

> Why this doesn’t work?
> 
> ActiveRecord::Base.connection.execute("\d") ?

Because you’re confusing commands the the psql application supports  
versus actual sql queries you can run. Execute lets you run arbitrary  
sql expressions, which “\d” isn’t (it also doesn’t do much with the  
result for you, so select\_all etc… are often more useful if there is  
data you are trying to get at)

Fred

(PS: ActiveRecord::Base.connection.tables)

---

<div class="post-metadata">

**Author:** ![luboherko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/b782af/32.png) [@luboherko](https://www.ruby-forum.com/u/luboherko)\
**Post date:** [March 6, 2009, 7:43pm UTC](https://www.ruby-forum.com/t/activerecord-base/162207/3 "2009-03-06T19:43:31Z")

</div>

Frederick C. wrote:

> On 6 Mar 2009, at 18:26, Lubomir Herko wrote:
> 
> > Why this doesn’t work?
> > 
> > ActiveRecord::Base.connection.execute("\d") ?
> 
> Because you’re confusing commands the the psql application supports  
> versus actual sql queries you can run. Execute lets you run arbitrary  
> sql expressions, which “\d” isn’t (it also doesn’t do much with the  
> result for you, so select\_all etc… are often more useful if there is  
> data you are trying to get at)
> 
> Fred
> 
> (PS: ActiveRecord::Base.connection.tables)

thanks… I was thinking that .execute() would not work with this level  
of command-line queries…
