created ticket 2104 for this which is now fixed.
On Mar 23, 2011, at 4:09 PM, botz wrote:
> Not sure if pickling of metadata is supported, but between 0.6.6 and
> 0.7b4 behavior has changed.
> The following works under 0.6.6, breaks under 0.7b4 . I've included
> the error below.
>
> ########################
> #!/usr/bin/env python
> import pickle
> import sqlalchemy
> from sqlalchemy import *
> from sqlalchemy.orm import *
> cachefile='cache'
> dbfile='database'
> engine = create_engine('sqlite:///%s' % dbfile,echo=True)
> metadata = MetaData(bind=engine)
>
>
> Table('a',metadata,
> Column('id',Integer,primary_key=True),
> Column('x', Integer, Sequence("x_seq"), ),
> )
> metadata.create_all()
> with open(cachefile, 'w') as cache:
> pickle.dump(metadata, cache)
>
>
> with open(cachefile, 'r') as cache:
> metadata2 = pickle.load(cache)
> metadata2.bind = engine
> Table('a',metadata2,
> Column('id',Integer,primary_key=True),
> Column('x', Integer, Sequence("x_seq"), ),
> useexisting=True)
>
>
> ###############
>
>
> Here's the error:
>
> Traceback (most recent call last):
> File "./picklebug.py", line 28, in <module>
> useexisting=True)
> File "/usr/local/lib/python2.7/site-packages/SQLAlchemy-0.7b4dev-
> py2.7-linux-i686.egg/sqlalchemy/schema.py", line 213, in __new__
> table._init_existing(*args, **kw)
> File "/usr/local/lib/python2.7/site-packages/SQLAlchemy-0.7b4dev-
> py2.7-linux-i686.egg/sqlalchemy/schema.py", line 318, in
> _init_existing
> self._init_items(*args)
> File "/usr/local/lib/python2.7/site-packages/SQLAlchemy-0.7b4dev-
> py2.7-linux-i686.egg/sqlalchemy/schema.py", line 62, in _init_items
> item._set_parent_with_dispatch(self)
> File "/usr/local/lib/python2.7/site-packages/SQLAlchemy-0.7b4dev-
> py2.7-linux-i686.egg/sqlalchemy/events.py", line 228, in
> _set_parent_with_dispatch
> self.dispatch.after_parent_attach(self, parent)
> File "/usr/local/lib/python2.7/site-packages/SQLAlchemy-0.7b4dev-
> py2.7-linux-i686.egg/sqlalchemy/event.py", line 239, in __call__
> fn(*args, **kw)
> File "/usr/local/lib/python2.7/site-packages/SQLAlchemy-0.7b4dev-
> py2.7-linux-i686.egg/sqlalchemy/schema.py", line 1519, in _set_table
> self._set_metadata(table.metadata)
> File "/usr/local/lib/python2.7/site-packages/SQLAlchemy-0.7b4dev-
> py2.7-linux-i686.egg/sqlalchemy/schema.py", line 1523, in
> _set_metadata
> self.metadata._sequences.add(self)
> AttributeError: 'MetaData' object has no attribute '_sequences'
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/sqlalchemy?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.