Forum: Ruby on Rails ActiveRecord::Base

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
5c7c9f1a025d72f3737d4c25327f61d5?d=identicon&s=25 Lubomir Herko (luboherko)
on 2009-03-06 19:26
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?
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-03-06 19:35
(Received via mailing list)
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)
5c7c9f1a025d72f3737d4c25327f61d5?d=identicon&s=25 Lubomir Herko (luboherko)
on 2009-03-06 19:43
Frederick Cheung 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..
This topic is locked and can not be replied to.