Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lJZuC-0004i6-Go for psycopg@arkaria.postgresql.org; Tue, 09 Mar 2021 10:48:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lJZuB-0008Cy-FO for psycopg@arkaria.postgresql.org; Tue, 09 Mar 2021 10:47:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lJZuB-0008Cq-8b for psycopg@lists.postgresql.org; Tue, 09 Mar 2021 10:47:59 +0000 Received: from mail-yb1-xb29.google.com ([2607:f8b0:4864:20::b29]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lJZu7-0001FV-Oc for psycopg@postgresql.org; Tue, 09 Mar 2021 10:47:58 +0000 Received: by mail-yb1-xb29.google.com with SMTP id u3so13476427ybk.6 for ; Tue, 09 Mar 2021 02:47:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hHo658LxnHplCcXc9G5xHKu55BnK87PJK8aWUx2t+aA=; b=KTfngI42ia7FnQRtfDFKCRmqt+UGiyCzRWUa9w8j2HzZJyik0C+sPoQYQcHTpdyqLm Ym1gFbLe7FiTGgCuYHsw4WSUijSm7aju9nLBgLQeIs7rQ/Eu0huDtJBi7mBdsSIUSWaW rRytvA+1zs3dKPbh5p++hnBZiNq1LuByjHx4ugmO8DO5XC1YT45yWAfNAXUFhOZ2QfZ0 0qmmAZG/r0Ei4LBYEUvgnA1tfG3Jo4dUCtq20BUCXVol3Cc9tzRhEr5lV4nNEqCLqD/A WzApA4Z2qE1b7ozjg/p8jXOKRvQ0uJ0O3zKC9oHznb9dtSx8cU8pCUf2Op/ZWEM+vKse WsRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hHo658LxnHplCcXc9G5xHKu55BnK87PJK8aWUx2t+aA=; b=tgej/m/bZnXhcGPD+8aNpbE5xavKjSQaHkKFm4ndcNCeYFwGqRg8l0H7/rRqZ4pkkZ r7nLJVbnGMvhNl/X/iY3ZhtIuMl2MaJnMx058eNJZi4cSAuLPv5GS/38dQQWIXeJFkRI QiOgBcJajZAn6mXCSNxFkt8aDTxPp231aCOqW+AjsP7Cu4idDTpFmyeBa2AcAGAQZ8rb 6+vUJ26RNC55AHpsiXYzUM/Vl/eGT+LlDi8x/5qBXvQCZCsuiJZZF8KX9AGncYJqz5gM GtFFcjABoy8ZJQV8qLieoRsXpVIE5BfxcczCyZCAub4GQ7sx7hR3uNXvIE3wifg2e6xd NdPg== X-Gm-Message-State: AOAM531eub8fj2EUkJTretGLGIzl1M30NDKC32YwpFwvHSBnPY0cj+tR dNDTWZvxy+xEbMRqosMWziGxfqpwN1zD6YrTdjOqmVW8c21lgS678QEzk5mDKU06pxL1bNYe79z 1oXcJjl8S2tdVLW7iqcERhuxakLBZMJyiePdBSZBya4gdv4quQ6YeK+t1fcaPM7ezVPUClxDj4I z/Xar7nP8PGFBsc+F6GkftJYVIr3QnGwYQ5xigdZIl0pv6 X-Google-Smtp-Source: ABdhPJx5AiX2oG4yRGr8nnF+eFDai5MCPp31B5y/ENoQhBqe/3CpRBk3dZXvLufK6PhBKqjl/jO1DEteODgU+egu5iM= X-Received: by 2002:a25:af02:: with SMTP id a2mr39956306ybh.270.1615286873953; Tue, 09 Mar 2021 02:47:53 -0800 (PST) MIME-Version: 1.0 References: <20210309104530.GN11758@artax.karlin.mff.cuni.cz> In-Reply-To: <20210309104530.GN11758@artax.karlin.mff.cuni.cz> From: Sebastiaan Mannem Date: Tue, 9 Mar 2021 11:47:42 +0100 Message-ID: Subject: Re: connect using env. variables To: Hans Ginzel Cc: psycopg@postgresql.org Content-Type: multipart/alternative; boundary="000000000000553e7905bd184862" X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000553e7905bd184862 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable How about emptystring (e.a. '')? Power to Postgres=E2=84=A2! Sebastiaan Mannem Product Manager M: +31 6 8252 1560 edbpostgres.com EDB, Anthony Fokkerweg 1, 1059 CM Amsterdam, The Netherlands On Tue, Mar 9, 2021 at 11:45 AM Hans Ginzel wrote: > Please, there should be a possibility to call connect() without parameter= s > for connecting using environment variables (PGSERVICE, PGDATABASE,=E2=80= =A6) > or defaults ($USER@localhost/postgres). > > Even pg uri postgres:// is valid, > https://www.postgresql.org/docs/current/libpq-connect.html. > > >>> d =3D psycopg2.connect(**parse_dsn('postgres://')) > Traceback (most recent call last): > File "", line 1, in > File "/usr/lib/python3/dist-packages/psycopg2/__init__.py", line 124, > in connect > raise TypeError('missing dsn and no parameters') > TypeError: missing dsn and no parameters > >>> d =3D psycopg2.connect(**parse_dsn('')) > Traceback (most recent call last): > File "", line 1, in > File "/usr/lib/python3/dist-packages/psycopg2/__init__.py", line 124, > in connect > raise TypeError('missing dsn and no parameters') > TypeError: missing dsn and no parameters > >>> db =3D psycopg2.connect() > Traceback (most recent call last): > File "", line 1, in > File "/usr/lib/python3/dist-packages/psycopg2/__init__.py", line 124, > in connect > raise TypeError('missing dsn and no parameters') > TypeError: missing dsn and no parameters > > Thank you in advance, > Hans > > > --000000000000553e7905bd184862 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
How about emptystring (e.a. '')?

Power to Postgres=E2=84=A2!

Sebastiaan Mannem

Product Manager



M= : +31 6 8252 1560

e= dbpostgres.com


EDB, Anthony Fokkerweg 1, 1059 CM Amsterdam, The Netherlands



On Tue, Mar 9, 2021 at 11:45 AM Hans Ginzel &= lt;hans@matfyz.cz> wrote:
Please, there should be = a possibility to call connect() without parameters
for connecting using environment variables (PGSERVICE, PGDATABASE,=E2=80=A6= )
or defaults ($USER@localhost/postgres).

Even pg uri postgres:// is valid,
https://www.postgresql.org/docs/current/l= ibpq-connect.html.

>>> d =3D psycopg2.connect(**parse_dsn('postgres://'))
Traceback (most recent call last):
=C2=A0 =C2=A0File "<stdin>", line 1, in <module>
=C2=A0 =C2=A0File "/usr/lib/python3/dist-packages/psycopg2/__init__.py= ", line 124, in connect
=C2=A0 =C2=A0 =C2=A0raise TypeError('missing dsn and no parameters'= )
TypeError: missing dsn and no parameters
>>> d =3D psycopg2.connect(**parse_dsn(''))
Traceback (most recent call last):
=C2=A0 =C2=A0File "<stdin>", line 1, in <module>
=C2=A0 =C2=A0File "/usr/lib/python3/dist-packages/psycopg2/__init__.py= ", line 124, in connect
=C2=A0 =C2=A0 =C2=A0raise TypeError('missing dsn and no parameters'= )
TypeError: missing dsn and no parameters
>>> db =3D psycopg2.connect()
Traceback (most recent call last):
=C2=A0 =C2=A0File "<stdin>", line 1, in <module>
=C2=A0 =C2=A0File "/usr/lib/python3/dist-packages/psycopg2/__init__.py= ", line 124, in connect
=C2=A0 =C2=A0 =C2=A0raise TypeError('missing dsn and no parameters'= )
TypeError: missing dsn and no parameters

Thank you in advance,
Hans


--000000000000553e7905bd184862--