SQLAlchemy raw sql vs expression language statements

后端 未结 1 644
-上瘾入骨i
-上瘾入骨i 2021-02-14 16:44

When inserting multiple rows in a MySQL-DB via a SQLA-Expression-Language statement, f.e.

Foo.__table__.insert().execute([{\'bar\': 1}, {\'bar\': 2}, {\'bar\': 3         


        
1条回答
  •  暖寄归人
    2021-02-14 17:39

    It seems that the special INSERT with multiple values only became recently supported(0.8 unreleased), you can see the note at the bottom of this section regarding the difference between executemany(what execute with a list does) and a multiple-VALUES INSERT:

    http://docs.sqlalchemy.org/ru/latest/core/expression_api.html#sqlalchemy.sql.expression.Insert.values

    This should explain the performance difference you see. You could try installing the development version and repeating the tests with the altered calling syntax, mentioned in the link, to confirm.

    0 讨论(0)
提交回复
热议问题