58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/lore/connection.rb', line 58
def self.get_connection(db_name)
db_name = db_name.intern unless db_name.instance_of? Symbol
if !@@pool.has_key? db_name then
begin
connection = PGconn.connect(Lore.pg_server, Lore.pg_port, '', '', db_name.to_s, Lore.user_for(db_name), Lore.pass_for(db_name.to_s))
connection.exec(Lore.on_connect_commands)
@@pool[db_name] = connection
rescue PGError => pge
raise Lore::Connection_Error.new("Could not establish connection to database '#{db_name.to_s}': " << pge.message)
rescue ::Exception => excep
raise Lore::Connection_Error.new("Could not establish connection to database '#{db_name.to_s}': " << excep.message)
end
end
return @@pool[db_name]
end
|