[sqlalchemy] Re: Using pickle to save reflected metadata

2006-12-08 Thread shday

I still get the error:

Traceback (most recent call last):
  File U:/ADA_tools/pickle_tables.py, line 27, in ?
pickle.dump(metadata_to_pickle,pfile)
  File C:\Python24\lib\pickle.py, line 1382, in dump
Pickler(file, protocol, bin).dump(obj)
  File C:\Python24\lib\pickle.py, line 231, in dump
self.save(obj)
  File C:\Python24\lib\pickle.py, line 338, in save
self.save_reduce(obj=obj, *rv)
  File C:\Python24\lib\pickle.py, line 433, in save_reduce
save(state)
  File C:\Python24\lib\pickle.py, line 293, in save
f(self, obj) # Call unbound method with explicit self
  File C:\Python24\lib\pickle.py, line 663, in save_dict
self._batch_setitems(obj.iteritems())
  File C:\Python24\lib\pickle.py, line 677, in _batch_setitems
save(v)
  File C:\Python24\lib\pickle.py, line 293, in save
f(self, obj) # Call unbound method with explicit self
  File C:\Python24\lib\pickle.py, line 663, in save_dict
self._batch_setitems(obj.iteritems())
  File C:\Python24\lib\pickle.py, line 677, in _batch_setitems
save(v)
  File C:\Python24\lib\pickle.py, line 338, in save
self.save_reduce(obj=obj, *rv)
  File C:\Python24\lib\pickle.py, line 433, in save_reduce
save(state)
  File C:\Python24\lib\pickle.py, line 293, in save
f(self, obj) # Call unbound method with explicit self
  File C:\Python24\lib\pickle.py, line 663, in save_dict
self._batch_setitems(obj.iteritems())
  File C:\Python24\lib\pickle.py, line 677, in _batch_setitems
save(v)
  File C:\Python24\lib\pickle.py, line 338, in save
self.save_reduce(obj=obj, *rv)
  File C:\Python24\lib\pickle.py, line 433, in save_reduce
save(state)
  File C:\Python24\lib\pickle.py, line 293, in save
f(self, obj) # Call unbound method with explicit self
  File C:\Python24\lib\pickle.py, line 663, in save_dict
self._batch_setitems(obj.iteritems())
  File C:\Python24\lib\pickle.py, line 677, in _batch_setitems
save(v)
  File C:\Python24\lib\pickle.py, line 338, in save
self.save_reduce(obj=obj, *rv)
  File C:\Python24\lib\pickle.py, line 433, in save_reduce
save(state)
  File C:\Python24\lib\pickle.py, line 293, in save
f(self, obj) # Call unbound method with explicit self
  File C:\Python24\lib\pickle.py, line 663, in save_dict
self._batch_setitems(obj.iteritems())
  File C:\Python24\lib\pickle.py, line 677, in _batch_setitems
save(v)
  File C:\Python24\lib\pickle.py, line 293, in save
f(self, obj) # Call unbound method with explicit self
  File C:\Python24\lib\pickle.py, line 663, in save_dict
self._batch_setitems(obj.iteritems())
  File C:\Python24\lib\pickle.py, line 676, in _batch_setitems
save(k)
  File C:\Python24\lib\pickle.py, line 338, in save
self.save_reduce(obj=obj, *rv)
  File C:\Python24\lib\pickle.py, line 433, in save_reduce
save(state)
  File C:\Python24\lib\pickle.py, line 293, in save
f(self, obj) # Call unbound method with explicit self
  File C:\Python24\lib\pickle.py, line 663, in save_dict
self._batch_setitems(obj.iteritems())
  File C:\Python24\lib\pickle.py, line 677, in _batch_setitems
save(v)
  File C:\Python24\lib\pickle.py, line 313, in save
rv = reduce(self.proto)
  File C:\Python24\lib\copy_reg.py, line 69, in _reduce_ex
raise TypeError, can't pickle %s objects % base.__name__
TypeError: can't pickle module objects


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Using pickle to save reflected metadata

2006-12-08 Thread Michael Bayer

latest trunk, this test works for me:

from sqlalchemy import *
meta = BoundMetaData('mysql://user:[EMAIL PROTECTED]/dbname')

table = Table('foo', meta, autoload=True)

meta2 = MetaData()

t2 = table.tometadata(meta2)

import pickle
pickle.dumps(meta2)

post your test case (with some sample table DDLs) and we'll try it out


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Using pickle to save reflected metadata

2006-12-08 Thread shday

whoops...

I've been using IDLE to test this and I guess it has to be reopened in
order for imports to be redone (I was just closing the shell window).
pickle.dump(metadata) works fine now.

But now I get a (recursive?) error when I try to unpickle (and I have
to kill the shell):

 import pickle
 pfile = file('pickled_tables','rb')
 metadata = pickle.load(pfile)

Traceback (most recent call last):
  File pyshell#7, line 1, in -toplevel-
metadata = pickle.load(pfile)
  File C:\Python24\lib\pickle.py, line 1390, in load
return Unpickler(file).load()
  File C:\Python24\lib\pickle.py, line 872, in load
dispatch[key](self)
  File C:\Python24\lib\pickle.py, line 1235, in load_build
setstate = getattr(inst, __setstate__, None)
  File C:\Python24\lib\site-packages\sqlalchemy\util.py, line 113, in
__getattr__
return self.__data[key]
  File C:\Python24\lib\site-packages\sqlalchemy\util.py, line 113, in
__getattr__
return self.__data[key]
  File C:\Python24\lib\site-packages\sqlalchemy\util.py, line 113, in
__getattr__
.
.
.
keeps on going


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Using pickle to save reflected metadata

2006-12-05 Thread Michael Bayer

you probably want to use toMetadata() on them with a plain MetaData
object so that the pickled stream does not contain any references to
engines.  then on the way back in you would call toMetadata() again
with your BoundMetaData (or Dynamic, whichever you are using).

if anything itll be a great test for the toMetadata() method which
doesnt have a lot of testing.


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~--~~~~--~~--~--~---