On Fri, Aug 28, 2015 at 8:16 PM, <ma...@tokbox.com> wrote:

> Hi,
>
> I am trying to generate sql scripts in offline mode. But when executing
> the delete in the following manner:
>
> op.execute(
>         foo.delete().where(foo.c.key == 'bar')
> )
>
>
> generates sql as
>
> DELETE FROM foo WHERE foo.`key` = %s;
>
>
>
> How can i get the actual value 'bar' instead of %s? Is there a better way
> to do this ? If I use raw sql statements I can get around the problem
> although I am trying my best to not execute raw sql statements in there.
>
That is ok, %s is later replaced with 'bar'.

For instance, this is the log I get when querying a table named role
filtering by id. The python code is :

role = session.query(model.Role).get(id_)

And the log entries are :

2015-08-29 08:01:53,461 INFO sqlalchemy.engine.base.Engine SELECT role.id
AS role_id, role.name AS role_name, role.is_admin AS role_is_admin
FROM role
WHERE role.id = %s
2015-08-29 08:01:53,462 INFO sqlalchemy.engine.base.Engine (2L,)

The first line shows the query to be executed with %s as place holder for
the parameters. The second line shows the parameters that will replace each
%s.

Martín

-- 

Martín

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy-alembic+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to