Hi all,
I am trying to use the session syntax to bind to an existing table,
but I am apparently missing something. I want my session to be bound
to this:

my_table = sqlalchemy.Table('my_table', meta, autoload=True,
autoload_with=engine)

and if I use the same engine here:

session = sqlalchemy.orm.sessionmaker(bind=engine, autoflush=True,
transactional=True)

isn't the session bound to the table?

But when I run this:

all_records = session.query(my_table).all()

I get this error:

Traceback (most recent call last):
  File "/usr/local/python/2.5.2/lib/python2.5/site-packages/
CherryPy-3.1.0beta3-py2.5.egg/cherrypy/_cprequest.py", line 588, in
respond
    cherrypy.response.body = self.handler()
  File "/usr/local/python/2.5.2/lib/python2.5/site-packages/
CherryPy-3.1.0beta3-py2.5.egg/cherrypy/_cpdispatch.py", line 24, in
__call__
    return self.callable(*self.args, **self.kwargs)
  File "/home/gloriajw/FU_OP/code/FU_OP.py", line 66, in run_report
    all_records = session.query(fu_op_purchases).all()
  File "/usr/local/python/2.5.2/lib/python2.5/site-packages/
SQLAlchemy-0.4.5-py2.5.egg/sqlalchemy/orm/session.py", line 739, in
query
    q = self._query_cls(mapper_or_class, self, **kwargs)
  File "/usr/local/python/2.5.2/lib/python2.5/site-packages/
SQLAlchemy-0.4.5-py2.5.egg/sqlalchemy/orm/query.py", line 63, in
__init__
    self.__init_mapper(_class_to_mapper(class_or_mapper,
entity_name=entity_name))
  File "/usr/local/python/2.5.2/lib/python2.5/site-packages/
SQLAlchemy-0.4.5-py2.5.egg/sqlalchemy/orm/query.py", line 69, in
__init_mapper
    self.table = self._from_obj = self.mapper.mapped_table
AttributeError: 'PGCompiler' object has no attribute 'mapped_table'

The docs I've seen only show session bindings using Table classes, so
please point me to a good example or give me the quick hint.

Thank you in advance,
Gloria

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to