Roundup Tracker - Issues

Message7904

Author rouilj
Recipients ivanov, rouilj
Date 2023-12-19.16:09:28
Message-id <20231219160925.4D8CE6A01F3@pe15.cs.umb.edu>
In-reply-to <f34484a53f47232cd013be25fbfdc0bc@riseup.net>
Hi Ivanov:

In message <f34484a53f47232cd013be25fbfdc0bc@riseup.net>,
Ivanov writes:
>> Somehow we are going to need to get the schema defined in
>> pg_service.conf out of libpg. I have no clue how to do that. Figuring
>> out what db is used is a major hack.
>
>> Gotcha. As I mentioned above I have no idea how to get the schema from
>> here.
>
>Can we get the connection parameters if it was not established
>successfully? If so, we can try to connect and store the values in a
>variable. Psycopg must return all connection values, including implicit
>ones.
>
>https://www.psycopg.org/docs/connection.html#connection.get_dsn_parameters
>
>This is just a guess, but it might be worth a try.

That returns the exact DSN i.e. "{'session': 'roundup_roundup'}", not
the params configured in .pg_session 8-(.

If I get a successful connection I can use
psycopg2.extensions.ConnectionInfo(connection) to get the
dbname. ConnectionInfo() provides dsn parameters plus other info in
newer way. However, the python API appears to be missing the
equivalent of current_schema() 8-/. I can get the options from
ConnectionInfo, but it's not broken out into components, so I have to
parse the options string to extract the schema.

On an unsuccessful connection (e.g. because the db doesn't exist yet),
I parse the exception message (arg):

   'connection to server at "127.0.0.1", port 5432 failed: FATAL:  database=
 "rounduptest" does not exist\n'

to extract the database name. Here's hoping the format of that message
doesn't change....

Have a great day.
--
				-- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.
History
Date User Action Args
2023-12-19 16:18:41adminsetinreplyto: f34484a53f47232cd013be25fbfdc0bc@riseup.net -> <f34484a53f47232cd013be25fbfdc0bc@riseup.net>
2023-12-19 16:18:06adminsetinreplyto: f34484a53f47232cd013be25fbfdc0bc@riseup.net
2023-12-19 16:09:28rouiljsetrecipients: + rouilj, ivanov
2023-12-19 16:09:28rouiljlinkissue2551299 messages
2023-12-19 16:09:28rouiljcreate