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

postgresql issue #3

Open
mountainpaul opened this issue Jun 17, 2016 · 9 comments
Open

postgresql issue #3

mountainpaul opened this issue Jun 17, 2016 · 9 comments

Comments

@mountainpaul
Copy link

error

File "/opt/.virtualenvs/yon-reports-my/lib/python2.7/site-packages/psycopg2/extras.py", line 487, in register_uuid
_ext.register_type(_ext.UUID, conn_or_curs)
TypeError: argument 2 must be a connection, cursor or None

import sqlalchemy_gevent
sqlalchemy_gevent.patch_all()
engine = create_engine('postgresql+psycopg2://xxxxxx:xxxxxx@localhost/yyyyy', isolation_level='AUTOCOMMIT')

@hkwi
Copy link
Owner

hkwi commented Jun 21, 2016

c2be7e0 fix this issue?

@j616
Copy link

j616 commented Feb 7, 2018

Sorry to re-awaken an old issue but I seem to be getting the same error with the current master. I think I have had this working on a local db with no user/password provided but the error happens when connecting with a user & password to a remote db. Judging by the original issue, it might be the username and/or password causing the error.

@hkwi
Copy link
Owner

hkwi commented Feb 10, 2018

Can I have some example code that I can reproduce the UUID problem?
I added some travis task, that tests connection with password and without password.

@j616
Copy link

j616 commented Feb 19, 2018

Sorry for the slow reply. I've been ill for a week.

I believe the following code should cause the issue

import sqlalchemy
import sqlalchemy_gevent
sqlalchemy_gevent.patch_all()

engine = sqlalchemy.create_engine("postgresql://<username>:<password>@<host>:<port>/<dbname>", pool_size=20)
connection = engine.connect().execution_options(autocommit=True)

Other methods of applying sqlalchemy_gevent also seem to have the issue.

hkwi added a commit that referenced this issue Feb 19, 2018
To reproduce #3
@hkwi
Copy link
Owner

hkwi commented Feb 19, 2018

I updated the test, but could not reproduce the issue.
https://travis-ci.org/hkwi/sqlalchemy_gevent/builds/343413177

Are you getting TypeError?

@j616
Copy link

j616 commented Feb 19, 2018

I am, yes. The exact same output as in the OP. I'm not in a position to run up a version with sqlalchemy_gevent at the moment but I'll try and post more info as soon as I am.

@j616
Copy link

j616 commented Feb 23, 2018

Hello. Sorry. Just got back into a position to test this. Here's a traceback from the example code I previously posted:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 2091, in connect
    return self._connection_cls(self, **kwargs)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 90, in __init__
    if connection is not None else engine.raw_connection()
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 2177, in raw_connection
    self.pool.unique_connection, _connection)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 2147, in _wrap_pool_connect
    return fn()
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 328, in unique_connection
    return _ConnectionFairy._checkout(self)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 766, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 516, in checkout
    rec = pool._do_get()
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 1138, in _do_get
    self._dec_overflow()
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 1135, in _do_get
    return self._create_connection()
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 333, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 461, in __init__
    self.__connect(first_connect_check=True)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 661, in __connect
    exec_once(self.connection, self)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/event/attr.py", line 246, in exec_once
    self(*args, **kw)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/event/attr.py", line 256, in __call__
    fn(*args, **kw)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/strategies.py", line 172, in on_connect
    do_on_connect(conn)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py", line 643, in on_connect
    fn(conn)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py", line 607, in on_connect
    extras.register_uuid(None, conn)
  File "/usr/lib64/python2.7/site-packages/psycopg2/extras.py", line 487, in register_uuid
    _ext.register_type(_ext.UUID, conn_or_curs)
TypeError: argument 2 must be a connection, cursor or None

@j616
Copy link

j616 commented Apr 9, 2018

Sorry. This work went on the back-burner for me. Doing some more searching, could it be a similar issue to this https://gist.github.com/mjallday/3d4c92e7e6805af1e024

@j616
Copy link

j616 commented Apr 10, 2018

@hkwi I also notice your travis tests are using a database on localhost. I've eliminated versions of other libraries as a factor in this. Local Vs Remote databases seem to be the only factor that might be breaking this.

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

No branches or pull requests

3 participants