[Sqlalchemy-tickets] Issue #4217: Can't pickle psycopg2.extensions objects (zzzeek/sqlalchemy)
Brought to you by:
zzzeek
From: Marat S. <iss...@bi...> - 2018-03-16 16:20:28
|
New issue 4217: Can't pickle psycopg2.extensions objects https://bitbucket.org/zzzeek/sqlalchemy/issues/4217/cant-pickle-psycopg2extensions-objects Marat Sharafutdinov: I'm using Python 3.6.4, SQLAlchemy 1.2.5 (psycopg2 2.7.4 as adapter) and PostgreSQL 10.3. Some exceptions are raised with `psycopg2.extensions` objects included. But I can't pickle these exceptions due to impossibility of pickling such objects. Listing `test_pg.py`: ``` #!python import pickle import sqlalchemy as sa url = 'postgresql://user:pass@host/test_db' engine = sa.create_engine(url, echo=True) connection = engine.connect() metadata = sa.MetaData() table = sa.Table('test_table', metadata, sa.Column('id', sa.Integer, primary_key=True), sa.Column('data', sa.LargeBinary), ) metadata.create_all(engine) try: engine.execute(table.insert(), {'id': 'invalid_integer', 'data': b'test'}) except Exception as exc: pickle.dumps(exc) ``` Output: ``` Traceback (most recent call last): File "test_pg.py", line 18, in <module> pickle.dumps(exc) TypeError: can't pickle psycopg2.extensions.Binary objects ``` Refs to https://github.com/psycopg/psycopg2/issues/688. |