On 10/29/2018 11:49 AM, Daniele Varrazzo wrote:
On Sun, Oct 28, 2018 at 9:35 PM Christian Ferrari <cam...@yahoo.com> wrote:

Dear All,
today I have released LIXA 1.7.1 with Python/Psycopg2 support.
To avoid two different methods (get_native_connection() for PostgreSQL and 
_get_native_connection() for MySQL/MariaDB) I have created a fork of Psycopg2 
https://github.com/tiian/psycopg2/tree/get-native-connection with the code provided by 
Federico and method "get_native_connection" renamed.
For the sake of convenience I have created a pull request: 
https://github.com/psycopg/psycopg2/pull/798 feel free to integrate it or to go 
on with the process you figured out in the past.
Kind Regards
Ch.F.

I don't know what Federico had decided but I'd very much prefer the
name without underscore. Methods with underscore don't belong to an
object interface.

Sorry for the late response, I was KO'ed by the flu. I agree with Daniele here but the fact that the *content* of the capsule, i.e., the PGconn* can change depending of the libpq version you're loading is pretty scary. I'd like to warn the client code (Python warnings to be suppressed? mm..) but just prepending an underscore to the method name doesn't mean much. If we add `get_native_connection()` then it becomes an official and supported psycopg extensions and doesn't make sense to mark it as private API.

There are always differences, in interfaces and in behaviour, between
dbapi drivers. A private method, returning two objects which are
different because they are very simply two database drivers, are not
the place where to start trying to unify interfaces. What you do, if
you want to deal with both drivers, is to write a wrapper unifying the
interfaces. I would be ok to adapt other drivers choices, if I agreed
with them, but I can't agree with an underscore method being
documented as part of the API: that's internal stuff and totally not
idiomatic Python.

My vote goes to have this method name without underscore, but I'll
leave the final decision to Federico.

Then without it is.

federico

--
Federico Di Gregorio                         federico.digrego...@dndg.it
DNDG srl                                                  http://dndg.it
 Credo fermamente che da qualche parte, in una scatola ci sia un gatto
  che non è vivo ne morto. Credo anche che se i fisici non si sbrigano
  a dargli una scatoletta, ben presto sarà solo morto.
                              -- adattato da una frase di Sam Black Crow

Reply via email to