Created
November 26, 2017 07:05
-
-
Save bosukh/19218171367f6258bdba27ea3483bb34 to your computer and use it in GitHub Desktop.
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
import time | |
from sqlalchemy.sql.expression import bindparam | |
def test_sqlalchemy_orm_update_in_chuck(n=100000): | |
init_sqlalchemy(False) | |
t0 = time.time() | |
customer = Customer.__table__ | |
stmt = customer.update().where(customer.c.id == bindparam('_id')).values( | |
{'name': bindparam('name')} | |
) | |
DBSession.execute(stmt, [{'name': 'NEW_NAME ' + str(i), '_id': i} for i in xrange(1, n+1)]) | |
DBSession.commit() | |
print( | |
"SQLAlchemy ORM list: Total time for " + str(n) + | |
" records " + str(time.time() - t0) + " secs") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment