Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Active Record: Query to find all the tables in a database?

Reply
Thread Tools

Active Record: Query to find all the tables in a database?

 
 
Anukul Singhal
Guest
Posts: n/a
 
      05-09-2008
Hi,

I am using the following code snippet to connect to a DB using Active
Record:

require 'rubygems'
require 'active_record'

ActiveRecord::Base.establish_connection(
:adapter => "sqlserver",
:host => "113.130.232.221,1342",
:username => "username",
assword => "password",
:database => "DIT_VW_1008"
)

It has about 25 tables. I want to print the names of all the tables in
the database "DIT_VW_1008". Can anyone provide the code to solve my
problem?

Thanks,
Anukul
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Prabhas Gupte
Guest
Posts: n/a
 
      05-09-2008
[Note: parts of this message were removed to make it a legal post.]

just for confirmation, do this:
con = ActiveRecord::Base.establish
>
> _connection(
> :adapter => "sqlserver",
> :host => "113.130.232.221,1342",
> :username => "username",
> assword => "password",
> :database => "DIT_VW_1008"
> )
>


print con.methods

On Fri, May 9, 2008 at 3:02 PM, Anukul Singhal <(E-Mail Removed)>
wrote:

> Hi,
>
> I am using the following code snippet to connect to a DB using Active
> Record:
>
> require 'rubygems'
> require 'active_record'
>
> ActiveRecord::Base.establish_connection(
> :adapter => "sqlserver",
> :host => "113.130.232.221,1342",
> :username => "username",
> assword => "password",
> :database => "DIT_VW_1008"
> )
>
> It has about 25 tables. I want to print the names of all the tables in
> the database "DIT_VW_1008". Can anyone provide the code to solve my
> problem?
>
> Thanks,
> Anukul
> --
> Posted via http://www.ruby-forum.com/.
>
>



--
Prabhas Gupte
Mob: +91 - 99 70 98 98 79
http://www.linkedin.com/in/prabhasgupte

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find out all active sessions in the asp.net web server?? Krish........... ASP .Net 2 02-16-2007 11:56 AM
How to get database metadata information (i.e. existing tables and columns in tables) Chris Brat Python 5 08-22-2006 05:25 PM
Tables within tables Otuatail HTML 7 08-02-2004 04:42 AM
Text after 2 tables actually appears between 2 tables ! Peter Bassett HTML 3 08-15-2003 06:46 PM



Advertisments