Browse Source

new util function 'get_host_params'

Alexander Verbitsky 9 years ago
parent
commit
9279aad5f5
1 changed files with 9 additions and 5 deletions
  1. 9 5
      src/epgsql_pool_utils.erl

+ 9 - 5
src/epgsql_pool_utils.erl

@@ -1,6 +1,7 @@
 -module(epgsql_pool_utils).
 
 -export([
+    get_host_params/1,
     new_connection/1,
     open_connection/1,
     close_connection/1,
@@ -10,16 +11,19 @@
 -include_lib("epgsql/include/epgsql.hrl").
 -include("epgsql_pool.hrl").
 
-new_connection(SectionName) ->
-    HostSection = wgconfig:get_string(SectionName, "db_host"),
-    % Connection parameters
-    Params = #epgsql_params{
+get_host_params(HostSection) ->
+    #epgsql_params{
         host                 = wgconfig:get_string(HostSection, "host"),
         port                 = wgconfig:get_int(HostSection, "port"),
         username             = wgconfig:get_string(HostSection, "username"),
         password             = wgconfig:get_string(HostSection, "password"),
         database             = wgconfig:get_string(HostSection, "database")
-    },
+    }.
+
+new_connection(SectionName) ->
+    HostSection = wgconfig:get_string(SectionName, "db_host"),
+    % Connection parameters
+    Params = get_host_params(HostSection),
     #epgsql_connection{
         connection_timeout   = wgconfig:get_int(SectionName, "connection_timeout"),
         query_timeout        = wgconfig:get_int(SectionName, "query_timeout"),