Skip site navigation (1) Skip section navigation (2)

Re: Mixing DictConnection and LoggingConnection

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: Alexey Luchko <luch(at)ank-sia(dot)com>
Cc: psycopg(at)postgresql(dot)org
Subject: Re: Mixing DictConnection and LoggingConnection
Date: 2012-05-09 10:22:47
Message-ID: CA+mi_8bDDOeAXxgM47=E8G0XWkvn331TxBc5XME+AQBXSriMbg@mail.gmail.com (view raw or flat)
Thread:
Lists: psycopg
On Wed, May 9, 2012 at 10:46 AM, Alexey Luchko <luch(at)ank-sia(dot)com> wrote:
> Hi!
>
> I was thinking of a connection object fetching dicts and reporting slow
> queries.  However, the way the connections classes are implemented make me
> think its impossible to create MyCursor(DictCursor, LoggingCursor) because
> they refer directly to parent class for calling inherited methods, like
> _cursor.method(....).
>
> Am I wrong?

Yes, as it is now I think you should subclass DictCursor yourself to add timing.

We should probably use super(), but mixin-style inheritance doesn't
just happen: the classes should be designed for it and I'm afraid they
weren't. I'm not even sure the base C classes are "new style" classes.
However, yes, I'm all for it: can you try patching the module so that
mixing up different orthogonal subclasses (e.g. logging vs.
namedtuple...) works as expected?

-- Daniele

In response to

psycopg by date

Next:From: Andy CaseyDate: 2012-05-10 08:26:56
Subject: Using a psycopg2 converter to retrieve bytea data from PostgreSQL
Previous:From: Alexey LuchkoDate: 2012-05-09 09:46:42
Subject: Mixing DictConnection and LoggingConnection

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group