Class: Database

Inherits:
Object
  • Object
show all
Defined in:
lib/peekdb/database.rb

Direct Known Subclasses

DatabaseMySQL, DatabasePSQL, DatabaseSQLite

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Database

Returns a new instance of Database.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/peekdb/database.rb', line 5

def initialize(name)
  @name = name

  begin
    open_connection(@name)
    puts "... Inspecting database #{@name}"

    find_tables
    puts "... Found #{@tables.size} tables"

    find_relations
    puts "... Found #{@relations.size} relations"
  rescue Exception => e
    puts "... Error FATAL: #{e}"
    exit(1)
  end
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



3
4
5
# File 'lib/peekdb/database.rb', line 3

def connection
  @connection
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/peekdb/database.rb', line 3

def name
  @name
end

#relationsObject (readonly)

Returns the value of attribute relations.



3
4
5
# File 'lib/peekdb/database.rb', line 3

def relations
  @relations
end

#tablesObject (readonly)

Returns the value of attribute tables.



3
4
5
# File 'lib/peekdb/database.rb', line 3

def tables
  @tables
end