Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

psycopg2 ver >= 2.8 adds connection.info object #11

Closed
mozartilize opened this issue Apr 19, 2019 · 0 comments · Fixed by #12
Closed

psycopg2 ver >= 2.8 adds connection.info object #11

mozartilize opened this issue Apr 19, 2019 · 0 comments · Fixed by #12

Comments

@mozartilize
Copy link

mozartilize commented Apr 19, 2019

I dont know where to report this, maybe it should be implemented in sqlalchemy but I'm quite not sure.

psycopg2 ver >= 2.8 adds connection.info object and the pool connection get from sqlalchemy pool actually has info object but it's an empty dict so it causes this error

In [1]: from django.db import connection                                                                                                                                                                                                                                          

In [2]: c = connection.cursor()                                                                                                                                                                                                                                                   
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-5783720e8456> in <module>
----> 1 c = connection.cursor()

~/.local/share/virtualenvs/atom-admin-py3.6/lib/python3.6/site-packages/django/db/backends/base/base.py in cursor(self)
    252         Creates a cursor, opening a connection if necessary.
    253         """
--> 254         return self._cursor()
    255 
    256     def commit(self):

~/.local/share/virtualenvs/atom-admin-py3.6/lib/python3.6/site-packages/django/db/backends/base/base.py in _cursor(self, name)
    227 
    228     def _cursor(self, name=None):
--> 229         self.ensure_connection()
    230         with self.wrap_database_errors:
    231             return self._prepare_cursor(self.create_cursor(name))

~/.local/share/virtualenvs/atom-admin-py3.6/lib/python3.6/site-packages/django/db/backends/base/base.py in ensure_connection(self)
    211         if self.connection is None:
    212             with self.wrap_database_errors:
--> 213                 self.connect()
    214 
    215     # ##### Backend-specific wrappers for PEP-249 connection methods #####

~/.local/share/virtualenvs/atom-admin-py3.6/lib/python3.6/site-packages/django/db/backends/base/base.py in connect(self)
    190         self.set_autocommit(self.settings_dict['AUTOCOMMIT'])
    191         self.init_connection_state()
--> 192         connection_created.send(sender=self.__class__, connection=self)
    193 
    194         self.run_on_commit = []

~/.local/share/virtualenvs/atom-admin-py3.6/lib/python3.6/site-packages/django/dispatch/dispatcher.py in send(self, sender, **named)
    191         return [
    192             (receiver, receiver(signal=self, sender=sender, **named))
--> 193             for receiver in self._live_receivers(sender)
    194         ]
    195 

~/.local/share/virtualenvs/atom-admin-py3.6/lib/python3.6/site-packages/django/dispatch/dispatcher.py in <listcomp>(.0)
    191         return [
    192             (receiver, receiver(signal=self, sender=sender, **named))
--> 193             for receiver in self._live_receivers(sender)
    194         ]
    195 

~/.local/share/virtualenvs/atom-admin-py3.6/lib/python3.6/site-packages/django/contrib/postgres/signals.py in register_type_handlers(connection, **kwargs)
     14             register_hstore(connection.connection, globally=True, unicode=True)
     15         else:
---> 16             register_hstore(connection.connection, globally=True)
     17     except ProgrammingError:
     18         # Hstore is not available on the database.

~/.local/share/virtualenvs/atom-admin-py3.6/lib/python3.6/site-packages/psycopg2/extras.py in register_hstore(conn_or_curs, globally, unicode, oid, array_oid)
    956     """
    957     if oid is None:
--> 958         oid = HstoreAdapter.get_oids(conn_or_curs)
    959         if oid is None or not oid[0]:
    960             raise psycopg2.ProgrammingError(

~/.local/share/virtualenvs/atom-admin-py3.6/lib/python3.6/site-packages/psycopg2/extras.py in get_oids(self, conn_or_curs)
    901 
    902         # column typarray not available before PG 8.3
--> 903         typarray = conn.info.server_version >= 80300 and "typarray" or "NULL"
    904 
    905         rv0, rv1 = [], []

AttributeError: 'dict' object has no attribute 'server_version'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant