Re: connect using env. variables

From: Sebastiaan Mannem <sebastiaan(dot)mannem(at)enterprisedb(dot)com>
To: Hans Ginzel <hans(at)matfyz(dot)cz>
Cc: psycopg(at)postgresql(dot)org
Subject: Re: connect using env. variables
Date: 2021-03-09 10:47:42
Message-ID: CAASsAGZCq2UOU_wmqO99kku5T3KwTOATi7NzdN_Zgk6mR-CWpA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

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 <hans(at)matfyz(dot)cz> wrote:

> Please, there should be a possibility to call connect() without parameters
> for connecting using environment variables (PGSERVICE, PGDATABASE,…)
> or defaults ($USER(at)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 "<stdin>", line 1, in <module>
> 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 "<stdin>", line 1, in <module>
> 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 "<stdin>", line 1, in <module>
> 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
>
>
>

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Hans Ginzel 2021-03-09 11:06:19 Re: connect using env. variables
Previous Message Hans Ginzel 2021-03-09 10:45:30 connect using env. variables