AttributeError: 'psycopg2._psycopg.connection' object has no attribute '_logger'

3,055 views
Skip to first unread message

Pau Tallada

unread,
May 30, 2014, 12:04:47 PM5/30/14
to sqlal...@googlegroups.com
Hi,

I don't know if I am doing something wrong :/
It also happens if instead of engine.connect().connection I use engine.raw_connection.

But I think that the error dissappears if you use a "standard" connection of something like that.
There has to be some side effect, because when I run this on the debugger, i does not always fail :/

    engine.connect().connection.cursor().copy_expert("COPY ({0}) TO STDOUT DELIMITER ' ' CSV".format(config['query']), open(full_catalog_filename_nfs, 'w'), size=65536)
  File "/nfs/pau/PAUdm/codes/jcarrete/envs_jcarrete/photoz_env/lib/python2.6/site-packages/SQLAlchemy-0.9.4-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1709, in connect
    return self._connection_cls(self, **kwargs)
  File "/nfs/pau/PAUdm/codes/jcarrete/envs_jcarrete/photoz_env/lib/python2.6/site-packages/SQLAlchemy-0.9.4-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 59, in __init__
    self.__connection = connection or engine.raw_connection()
  File "/nfs/pau/PAUdm/codes/jcarrete/envs_jcarrete/photoz_env/lib/python2.6/site-packages/SQLAlchemy-0.9.4-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1778, in raw_connection
    return self.pool.unique_connection()
  File "/nfs/pau/PAUdm/codes/jcarrete/envs_jcarrete/photoz_env/lib/python2.6/site-packages/SQLAlchemy-0.9.4-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 273, in unique_connection
    return _ConnectionFairy._checkout(self)
  File "/nfs/pau/PAUdm/codes/jcarrete/envs_jcarrete/photoz_env/lib/python2.6/site-packages/SQLAlchemy-0.9.4-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 626, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/nfs/pau/PAUdm/codes/jcarrete/envs_jcarrete/photoz_env/lib/python2.6/site-packages/SQLAlchemy-0.9.4-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 433, in checkout
    rec = pool._do_get()
  File "/nfs/pau/PAUdm/codes/jcarrete/envs_jcarrete/photoz_env/lib/python2.6/site-packages/SQLAlchemy-0.9.4-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 945, in _do_get
    return self._create_connection()
  File "/nfs/pau/PAUdm/codes/jcarrete/envs_jcarrete/photoz_env/lib/python2.6/site-packages/SQLAlchemy-0.9.4-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 278, in _create_connection
    return _ConnectionRecord(self)
  File "/nfs/pau/PAUdm/codes/jcarrete/envs_jcarrete/photoz_env/lib/python2.6/site-packages/SQLAlchemy-0.9.4-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 409, in __init__
    exec_once(self.connection, self)
  File "/nfs/pau/PAUdm/codes/jcarrete/envs_jcarrete/photoz_env/lib/python2.6/site-packages/SQLAlchemy-0.9.4-py2.6-linux-x86_64.egg/sqlalchemy/event/attr.py", line 247, in exec_once
    self(*args, **kw)
  File "/nfs/pau/PAUdm/codes/jcarrete/envs_jcarrete/photoz_env/lib/python2.6/site-packages/SQLAlchemy-0.9.4-py2.6-linux-x86_64.egg/sqlalchemy/event/attr.py", line 257, in __call__
    fn(*args, **kw)
  File "/nfs/pau/PAUdm/codes/jcarrete/envs_jcarrete/photoz_env/lib/python2.6/site-packages/SQLAlchemy-0.9.4-py2.6-linux-x86_64.egg/sqlalchemy/util/langhelpers.py", line 1203, in go
    return once_fn(*arg, **kw)
  File "/nfs/pau/PAUdm/codes/jcarrete/envs_jcarrete/photoz_env/lib/python2.6/site-packages/SQLAlchemy-0.9.4-py2.6-linux-x86_64.egg/sqlalchemy/engine/strategies.py", line 165, in first_connect
    dialect.initialize(c)
  File "/nfs/pau/PAUdm/codes/jcarrete/envs_jcarrete/photoz_env/lib/python2.6/site-packages/SQLAlchemy-0.9.4-py2.6-linux-x86_64.egg/sqlalchemy/dialects/postgresql/psycopg2.py", line 390, in initialize
    super(PGDialect_psycopg2, self).initialize(connection)
  File "/nfs/pau/PAUdm/codes/jcarrete/envs_jcarrete/photoz_env/lib/python2.6/site-packages/SQLAlchemy-0.9.4-py2.6-linux-x86_64.egg/sqlalchemy/dialects/postgresql/base.py", line 1576, in initialize
    "show standard_conforming_strings"
  File "/nfs/pau/PAUdm/codes/jcarrete/envs_jcarrete/photoz_env/lib/python2.6/site-packages/SQLAlchemy-0.9.4-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 650, in scalar
    return self.execute(object, *multiparams, **params).scalar()
  File "/nfs/pau/PAUdm/codes/jcarrete/envs_jcarrete/photoz_env/lib/python2.6/site-packages/SQLAlchemy-0.9.4-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 712, in execute
    return self._execute_text(object, multiparams, params)
  File "/nfs/pau/PAUdm/codes/jcarrete/envs_jcarrete/photoz_env/lib/python2.6/site-packages/SQLAlchemy-0.9.4-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 861, in _execute_text
    statement, parameters
  File "/nfs/pau/PAUdm/codes/jcarrete/envs_jcarrete/photoz_env/lib/python2.6/site-packages/SQLAlchemy-0.9.4-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 947, in _execute_context
    context)
  File "/nfs/pau/PAUdm/codes/jcarrete/envs_jcarrete/photoz_env/lib/python2.6/site-packages/SQLAlchemy-0.9.4-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1097, in _handle_dbapi_exception
    self._safe_close_cursor(cursor)
  File "/nfs/pau/PAUdm/codes/jcarrete/envs_jcarrete/photoz_env/lib/python2.6/site-packages/SQLAlchemy-0.9.4-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1050, in _safe_close_cursor
    self.connection._logger.error(
AttributeError: 'psycopg2._psycopg.connection' object has no attribute '_logger'


--
----------------------------------
Pau Tallada Crespí
Dep. d'Astrofísica i Cosmologia
Port d'Informació Científica (PIC)
----------------------------------

Michael Bayer

unread,
May 30, 2014, 12:36:18 PM5/30/14
to sqlal...@googlegroups.com

is that happening every time?  it’s a bug where an exception is raised on connect but it’s not being allowed to display.   Can you please invoke the statement “show standard_conforming_strings” on your connection and/or Postgresql database so I can see what it’s saying?





--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com.
To post to this group, send email to sqlal...@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Michael Bayer

unread,
May 30, 2014, 4:26:58 PM5/30/14
to sqlal...@googlegroups.com
The exception here is fixed in master, rel_1_0 and rel_0_9 branches, it is https://bitbucket.org/zzzeek/sqlalchemy/issue/3063/engine-base-safe_close_cursor-assumes-our.   That is, it won’t choke trying to log the cursor close error.    But there’s still an error that was raised here when this occurred, if it happens on the new code, you’ll get the error that really happened.

Pau Tallada

unread,
Jun 2, 2014, 8:16:12 AM6/2/14
to sqlal...@googlegroups.com
Hi Michael,

It did not happen every time. I'm pretty sure with 0.8.x it did not happen.

show standard_conforming_strings --> on

About the Exception...
Could it be this one?: AttributeError("'module' object has no attribute 'ps2'",)

Thank you very much!

Pau.

Pau Tallada

unread,
Jun 2, 2014, 8:27:25 AM6/2/14
to sqlal...@googlegroups.com
Or this one:
(Pdb) p cursor.close()
*** InternalError: InternalError('current transaction is aborted, commands ignored until end of transaction block\n',)

Michael Bayer

unread,
Jun 2, 2014, 9:45:05 AM6/2/14
to sqlal...@googlegroups.com
I have no idea what that error is.   Seems like something local to your application.

Michael Bayer

unread,
Jun 2, 2014, 9:45:43 AM6/2/14
to sqlal...@googlegroups.com

OK, anyway, the issue is fixed so that particular error (which is very common in PG after an error has occurred) will just be a warning.

On Jun 2, 2014, at 8:26 AM, Pau Tallada <tal...@pic.es> wrote:

Or this one:
(Pdb) p cursor.close()
*** InternalError: InternalError('current transaction is aborted, commands ignored until end of transaction block\n',)

2014-06-02 14:15 GMT+02:00 Pau Tallada <tal...@pic.es>:
Hi Michael,

It did not happen every time. I'm pretty sure with 0.8.x it did not happen.

show standard_conforming_strings --> on

About the Exception...
Could it be this one?: AttributeError("'module' object has no attribute 'ps2'",)

Thank you very much!

Pau.

2014-05-30 22:26 GMT+02:00 Michael Bayer <mik...@zzzcomputing.com>:

The exception here is fixed in master, rel_1_0 and rel_0_9 branches, it ishttps://bitbucket.org/zzzeek/sqlalchemy/issue/3063/engine-base-safe_close_cursor-assumes-our.   That is, it won’t choke trying to log the cursor close error.    But there’s still an error that was raised here when this occurred, if it happens on the new code, you’ll get the error that really happened.
To post to this group, send email to sqlal...@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.



-- 
----------------------------------
Pau Tallada Crespí
Dep. d'Astrofísica i Cosmologia
Port d'Informació Científica (PIC)
----------------------------------




-- 
----------------------------------
Pau Tallada Crespí
Dep. d'Astrofísica i Cosmologia
Port d'Informació Científica (PIC)
----------------------------------

Reply all
Reply to author
Forward
0 new messages