Thread: Map connection().status() to name?

Map connection().status() to name?

From
Jim Nasby
Date:
I realize that there are constants in psycopg2.extensions for available
connection statuses and what-not, but is there any included way to map a
returned status to a descriptive string? When I'm trying to debug
something a status of '2' doesn't really tell me anything useful. :(
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com
855-TREBLE2 (855-873-2532)   mobile: 512-569-9461


Re: Map connection().status() to name?

From
Jim Nasby
Date:
On 11/11/16 2:14 PM, Jim Nasby wrote:
> I realize that there are constants in psycopg2.extensions for available
> connection statuses and what-not, but is there any included way to map a
> returned status to a descriptive string? When I'm trying to debug
> something a status of '2' doesn't really tell me anything useful. :(

Would a patch implementing such a map be accepted?
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com
855-TREBLE2 (855-873-2532)


Re: Map connection().status() to name?

From
Daniele Varrazzo
Date:
On Fri, Nov 18, 2016 at 8:47 PM, Jim Nasby <Jim.Nasby@bluetreble.com> wrote:
> On 11/11/16 2:14 PM, Jim Nasby wrote:
>>
>> I realize that there are constants in psycopg2.extensions for available
>> connection statuses and what-not, but is there any included way to map a
>> returned status to a descriptive string? When I'm trying to debug
>> something a status of '2' doesn't really tell me anything useful. :(
>
>
> Would a patch implementing such a map be accepted?

I don't see why not. What constant do you want to reverse? The groups
in `extensions` are status, isolation level, transaction status. Would
you provide 3 different functions to reverse them?

-- Daniele


Re: Map connection().status() to name?

From
Jim Nasby
Date:
On 11/18/16 5:34 PM, Daniele Varrazzo wrote:
> I don't see why not. What constant do you want to reverse? The groups
> in `extensions` are status, isolation level, transaction status. Would
> you provide 3 different functions to reverse them?

That's what I was thinking.

Would there be any value in being able to map back to the constants
themselves? I can't really think of any use for that, but I'm not really
a python guy so...
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com
855-TREBLE2 (855-873-2532)