[sqlalchemy] UnboundExecutionError: text query with elixir

2011-02-28 Thread David Borsodi
Hello,

I'm trying to run the following query with elixir entities:

elixir.metadata.bind = 'mysql://root:root@localhost/mutdb'
elixir.metadata.bind.echo = True
elixir.setup_all(True)

t = text(select * from mutations)
result = elixir.session.connection().execute(t)

and I got:
sqlalchemy.exc.UnboundExecutionError: This session is not bound to a
single Engine or Connection, and no context was provided to locate a
binding.

I though elixir does all the initialization with setup_all(), what
else is needed to run queries like this?
Normal mapped queries like Mutation.query.all() work normally.


thanks
david

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] UnboundExecutionError: text query with elixir

2011-02-28 Thread Michael Bayer

On Feb 28, 2011, at 9:05 AM, David Borsodi wrote:

 Hello,
 
 I'm trying to run the following query with elixir entities:
 
 elixir.metadata.bind = 'mysql://root:root@localhost/mutdb'
 elixir.metadata.bind.echo = True
 elixir.setup_all(True)
 
 t = text(select * from mutations)
 result = elixir.session.connection().execute(t)
 
 and I got:
 sqlalchemy.exc.UnboundExecutionError: This session is not bound to a
 single Engine or Connection, and no context was provided to locate a
 binding.
 
 I though elixir does all the initialization with setup_all(), what
 else is needed to run queries like this?
 Normal mapped queries like Mutation.query.all() work normally.

I would have thought Elixir associates the engine with the Session, if not you 
may ask on their list.

You can associate the contextual session (i.e. , a ScopedSession wrapper) with 
a bind by doing:

session.configure(bind=engine)

before the contextual session is first used.


-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] UnboundExecutionError: text query with elixir

2011-02-28 Thread David Borsodi
Yes, I also looked and the elixir session is an SA ScopedSession, I'll try
the explicit bind.

thanks
david

On Mon, Feb 28, 2011 at 5:58 PM, Michael Bayer mike...@zzzcomputing.comwrote:

 ssociates the engine wit

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.