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 1lJaC1-0005Na-Mz for psycopg@arkaria.postgresql.org; Tue, 09 Mar 2021 11:06:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lJaC0-0004zz-DO for psycopg@arkaria.postgresql.org; Tue, 09 Mar 2021 11:06:24 +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 1lJaC0-0004zs-7q for psycopg@lists.postgresql.org; Tue, 09 Mar 2021 11:06:24 +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 1lJaBy-0001Nk-0D for psycopg@postgresql.org; Tue, 09 Mar 2021 11:06:23 +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 32B19205F8; Tue, 9 Mar 2021 12:06:20 +0100 (CET) Received: by artax.karlin.mff.cuni.cz (Postfix, from userid 1975) id 14E60828001; Tue, 9 Mar 2021 12:06:20 +0100 (CET) Date: Tue, 9 Mar 2021 12:06:19 +0100 From: Hans Ginzel To: Sebastiaan Mannem Cc: psycopg@postgresql.org Subject: Re: connect using env. variables Message-ID: <20210309110619.GO11758@artax.karlin.mff.cuni.cz> References: <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 In-Reply-To: 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 Empty string does not work for **parse_dsn(), see example below. H. On Tue, Mar 09, 2021 at 11:47:42AM +0100, Sebastiaan Mannem wrote: >How about emptystring (e.a. '')? > >Power to Postgres™! > > >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 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 >> >> >>