Jonathan LaCour wrote:
 > ### EXAMPLE TWO: use the metadata on the activemapper module ###

This works.

> ### EXAMPLE ONE: specify engine on the class itself ###

This doesn't.

$ cat test2.py
import sqlalchemy.mods.threadlocal
from sqlalchemy import *
from sqlalchemy.ext.activemapper import *

engine = create_engine('sqlite:///:memory:')

class Foo(ActiveMapper):
     class mapping:
         __table__  = 'foo_tbl'
         __engine__ = engine
         foo_id     = column(Integer, primary_key=True)
         foo_text   = column(String(30))

Foo.table.create()
f = Foo(foo_text='test').flush()

$ python test2.py
Traceback (most recent call last):
   File "test2.py", line 14, in ?
     Foo.table.create()
   File "/home/ccd/VC/svn/sqlalchemy/lib/sqlalchemy/schema.py", line 
227, in create
     self.engine.create(self)
   File "/home/ccd/VC/svn/sqlalchemy/lib/sqlalchemy/schema.py", line 41, 
in <lambda>
     engine = property(lambda s:s._get_engine())
   File "/home/ccd/VC/svn/sqlalchemy/lib/sqlalchemy/schema.py", line 40, 
in _get_engine
     return self._derived_metadata().engine
   File "/home/ccd/VC/svn/sqlalchemy/lib/sqlalchemy/schema.py", line 
718, in <lambda>
     engine=property(lambda s:s.context._engine)
   File "/home/ccd/VC/svn/sqlalchemy/lib/sqlalchemy/util.py", line 189, 
in __getattr__
     raise AttributeError(key)
AttributeError: _engine



_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to