Class: DatabaseMethods

Inherits:
Object
  • Object
show all
Defined in:
lib/anhpham/methods/database_methods.rb

Class Method Summary collapse

Class Method Details

.close_connection(schema) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/anhpham/methods/database_methods.rb', line 15

def self.close_connection (schema)
  case $db_type.to_sym
    when :sql_server then
      conn = IFD_Connections.get_sql_server_db_connection(schema)
      conn.close
    when :mysql then
      conn = IFD_Connections.get_mysql_db_connection(schema)
      conn.close
  end
end

.execute_select(schema, sql) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/anhpham/methods/database_methods.rb', line 2

def self.execute_select (schema,sql)
  case $db_type.to_sym
    when :sql_server then
      conn = IFD_Connections.get_sql_server_db_connection(schema)
      conn.execute sql
    when :mysql then
      conn = IFD_Connections.get_mysql_db_connection(schema)
      conn.query sql
    else
      raise "*** ERROR: schema type (#{$db_type}) is not supported (SQL SERVER, MY SQL)."
  end
end