On 11/06/2015 03:04 PM, vitaly numenta wrote:
> Hi, I am using sqlalchemy core with the mysql dialect. Mysql supports
> DELETE with ORDER BY and LIMIT:
> 
> DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name
>     [PARTITION (partition_name,...)]
>     [WHERE where_condition]
>     [ORDER BY ...]
>     [LIMIT row_count]
> 
> 
> However, I can't seem to figure out how to do this via sqlalchemy core.

emit the exact SQL you want as a string:

conn.execute("DELETE .... WHERE  ... ORDER BY ... LIMIT")

the query is MySQL specific in any case so you wouldn't need to worry
about portability.

I seem to recall a ticket asking for this feature but at the moment I
can only find one referring to DELETE FROM .. JOIN for MySQL.




> I have a really large table from which I need to garbage-collect old
> rows now and then. When I try to do it all in one operation, I end up
> getting "Lock wait timeout exceeded; try restarting transaction", so I
> wanted to take advantage of order_by and limit to do this incrementally,
> but mysqlalchemy won't let me.
> 
> Please help.
> 
> Thank you,
> Vitaly
> 
> -- 
> 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
> <mailto:sqlalchemy-alembic+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

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