@@ -59,15 +59,10 @@ Connects to the database and returns a handle.
59
59
function SearchLight. connect (conn_data:: Dict = SearchLight. config. db_config_settings) :: DatabaseHandle
60
60
dns = String[]
61
61
62
- haskey (conn_data, " host" ) && push! (dns, string (" host=" , conn_data[" host" ]))
63
- haskey (conn_data, " hostaddr" ) && push! (dns, string (" hostaddr=" , conn_data[" hostaddr" ]))
64
- haskey (conn_data, " port" ) && push! (dns, string (" port=" , conn_data[" port" ]))
65
- haskey (conn_data, " database" ) && push! (dns, string (" dbname=" , conn_data[" database" ]))
66
- haskey (conn_data, " username" ) && push! (dns, string (" user=" , conn_data[" username" ]))
67
- haskey (conn_data, " password" ) && push! (dns, string (" password=" , conn_data[" password" ]))
68
- haskey (conn_data, " passfile" ) && push! (dns, string (" passfile=" , conn_data[" passfile" ]))
69
- haskey (conn_data, " connect_timeout" ) && push! (dns, string (" connect_timeout=" , conn_data[" connect_timeout" ]))
70
- haskey (conn_data, " client_encoding" ) && push! (dns, string (" client_encoding=" , conn_data[" client_encoding" ]))
62
+ for key in [" host" , " hostaddr" , " port" , " database" , " username" , " password" , " passfile" , " connect_timeout" , " client_encoding" ]
63
+ get! (conn_data, key, get (ENV , " SEARCHLIGHT_$(uppercase (key)) " , nothing ))
64
+ conn_data[key] != = nothing && push! (dns, string (" $key =" , conn_data[key]))
65
+ end
71
66
72
67
push! (CONNECTIONS, LibPQ. Connection (join (dns, " " )))[end ]
73
68
end
0 commit comments