Wednesday, July 6, 2016

Modified postgresql backend

Hello,

I need to create my own modified backend based on postgresql database backend, which use my wrapper for psycopg2 driver.
I tried to simply subclass django.db.backends.postgresql.DatabaseWrapper and redefine DatabaseWrapper.Database class member, but faced the fact that inside the class the <module>.Database member is used (in get_new_connection and is_usable methods) instead of self.Database.

I think, this is bug, isn't it?
I simply copy-pasted those two methods into my subclass and added self. , however, I think, this should be fixed in the library:

Here is my db.backends.my_postgresql.base file content:

####################################################
from django.db.backends.postgresql_psycopg2.base import *
from db.drivers import my_psycopg2

class DatabaseWrapper(DatabaseWrapper):
    Database = my_psycopg2

    def get_new_connection(self, conn_params):
        connection = self.Database.connect(**conn_params) # here I added 'self.'
        ...

####################################################
--
Alexander

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/132bc444-dd91-435e-8058-c195fffd0466%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment