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

Discussion in 'Ruby' started by Anukul Singhal, May 9, 2008.

  1. 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",
    :password => "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/.
     
    Anukul Singhal, May 9, 2008
    #1
    1. Advertising

  2. [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",
    > :password => "password",
    > :database => "DIT_VW_1008"
    > )
    >


    print con.methods

    On Fri, May 9, 2008 at 3:02 PM, Anukul Singhal <>
    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",
    > :password => "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
     
    Prabhas Gupte, May 9, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Brat
    Replies:
    5
    Views:
    711
    =?iso-8859-1?q?Luis_M._Gonz=E1lez?=
    Aug 22, 2006
  2. Krish...........
    Replies:
    2
    Views:
    1,205
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
    Feb 16, 2007
  3. Replies:
    7
    Views:
    203
    Jacko
    Jul 26, 2007
  4. Anukul Singhal

    Writing a SQL Query in Active Record?

    Anukul Singhal, May 8, 2008, in forum: Ruby
    Replies:
    5
    Views:
    200
    Phillip Gawlowski
    May 8, 2008
  5. Idealone Ideally
    Replies:
    5
    Views:
    136
    Idealone Ideally
    Jan 28, 2010
Loading...

Share This Page