ActiveRecord::Base

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?

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)

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…