Created
February 3, 2012 15:13
-
-
Save kung-foo/1730627 to your computer and use it in GitHub Desktop.
ON DUPLICATE KEY UPDATE hack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlalchemy.ext.compiler import compiles | |
from sqlalchemy.sql.expression import Insert | |
@compiles(Insert) | |
def append_string(insert, compiler, **kw): | |
s = compiler.visit_insert(insert, **kw) | |
if 'append_string' in insert.kwargs: | |
return s + " " + insert.kwargs['append_string'] | |
return s | |
my_connection.execute(my_table.insert(append_string = 'ON DUPLICATE KEY UPDATE foo=foo'), my_values) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
All the method above can't work.
And get error