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 1lJZrx-0004eo-7Y for psycopg@arkaria.postgresql.org; Tue, 09 Mar 2021 10:45:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lJZrv-0007sR-M8 for psycopg@arkaria.postgresql.org; Tue, 09 Mar 2021 10:45:39 +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 1lJZrv-0007sJ-Gm for psycopg@lists.postgresql.org; Tue, 09 Mar 2021 10:45:39 +0000 Received: from postak.karlin.mff.cuni.cz ([195.113.30.11]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lJZrr-0001Ex-5F for psycopg@postgresql.org; Tue, 09 Mar 2021 10:45:38 +0000 Received: from artax.karlin.mff.cuni.cz (artax.karlin.mff.cuni.cz [195.113.26.195]) by postak.karlin.mff.cuni.cz (Postfix) with ESMTPS id BE2BC205F8 for ; Tue, 9 Mar 2021 11:45:30 +0100 (CET) Received: by artax.karlin.mff.cuni.cz (Postfix, from userid 1975) id A2E66828001; Tue, 9 Mar 2021 11:45:30 +0100 (CET) Date: Tue, 9 Mar 2021 11:45:30 +0100 From: Hans Ginzel To: psycopg@postgresql.org Subject: connect using env. variables Message-ID: <20210309104530.GN11758@artax.karlin.mff.cuni.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.5.21 (2010-09-15) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Please, there should be a possibility to call connect() without parameters for connecting using environment variables (PGSERVICE, PGDATABASE,…) or defaults ($USER@localhost/postgres). Even pg uri postgres:// is valid, https://www.postgresql.org/docs/current/libpq-connect.html. >>> d = 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 = 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 = 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