29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/async/sequel/postgres/database.rb', line 29
def connect(server)
opts = server_opts(server)
connection_params = {
:host => opts[:host],
:port => opts[:port],
:dbname => opts[:database],
:user => opts[:user],
:password => opts[:password],
:connect_timeout => opts[:connect_timeout] || 20,
:sslmode => opts[:sslmode],
:sslrootcert => opts[:sslrootcert]
}.delete_if { |key, value| blank_object?(value) }
connection_params.merge!(opts[:driver_options]) if opts[:driver_options]
conn = Adapter.new(self, opts[:conn_str] || connection_params)
if receiver = opts[:notice_receiver]
conn.set_notice_receiver(&receiver)
end
if conn.respond_to?(:type_map_for_queries=) && defined?(self::PG_QUERY_TYPE_MAP)
conn.type_map_for_queries = self::PG_QUERY_TYPE_MAP
end
if encoding = opts[:encoding] || opts[:charset]
if conn.respond_to?(:set_client_encoding)
conn.set_client_encoding(encoding)
else
conn.async_exec("set client_encoding to '#{encoding}'")
end
end
connection_configuration_sqls(opts).each{|sql| conn.execute(sql)}
conn
end
|