@@ -272,7 +272,8 @@ def _dot_postgresql_path(filename) -> typing.Optional[pathlib.Path]:
272
272
273
273
274
274
def _parse_connect_dsn_and_args (* , dsn , host , port , user ,
275
- password , passfile , database , ssl , service ,
275
+ password , passfile , database , ssl ,
276
+ service , servicefile ,
276
277
direct_tls , server_settings ,
277
278
target_session_attrs , krbsrvname , gsslib ):
278
279
# `auth_hosts` is the version of host information for the purposes
@@ -297,7 +298,11 @@ def _parse_connect_dsn_and_args(*, dsn, host, port, user,
297
298
if not service and val :
298
299
service = val
299
300
300
- connection_service_file = os .getenv ('PGSERVICEFILE' )
301
+ connection_service_file = servicefile
302
+
303
+ if connection_service_file is None :
304
+ connection_service_file = os .getenv ('PGSERVICEFILE' )
305
+
301
306
if connection_service_file is None :
302
307
homedir = compat .get_pg_home_directory ()
303
308
if homedir :
@@ -859,7 +864,7 @@ def _parse_connect_arguments(*, dsn, host, port, user, password, passfile,
859
864
max_cacheable_statement_size ,
860
865
ssl , direct_tls , server_settings ,
861
866
target_session_attrs , krbsrvname , gsslib ,
862
- service ):
867
+ service , servicefile ):
863
868
local_vars = locals ()
864
869
for var_name in {'max_cacheable_statement_size' ,
865
870
'max_cached_statement_lifetime' ,
@@ -889,7 +894,8 @@ def _parse_connect_arguments(*, dsn, host, port, user, password, passfile,
889
894
direct_tls = direct_tls , database = database ,
890
895
server_settings = server_settings ,
891
896
target_session_attrs = target_session_attrs ,
892
- krbsrvname = krbsrvname , gsslib = gsslib , service = service )
897
+ krbsrvname = krbsrvname , gsslib = gsslib ,
898
+ service = service , servicefile = servicefile )
893
899
894
900
config = _ClientConfiguration (
895
901
command_timeout = command_timeout ,
0 commit comments