Why does SQLAlchemy session not execute SQL operations via its bounded connection? -
code:
import app flaskr app = flaskr.app app.config.from_pyfile('config.py') connection = flaskr.db.engine.connect() session = flaskr.db.create_scoped_session( options=dict(bind=connection, binds={})) obj = object(...) session.add(obj) session.commit() """ debug:sqlalchemy.pool.queuepool:created new connection <_mysql.connection open '******' @ 208f590> info:sqlalchemy.engine.base.engine:show variables 'sql_mode' info:sqlalchemy.engine.base.engine:() info:sqlalchemy.engine.base.engine:() info:sqlalchemy.engine.base.engine:show collation `charset` = 'utf8' , `collation` = 'utf8_bin' info:sqlalchemy.engine.base.engine:() info:sqlalchemy.engine.base.engine:select cast('test plain returns' char(60)) anon_1 info:sqlalchemy.engine.base.engine:() info:sqlalchemy.engine.base.engine:select cast('test unicode returns' char(60)) anon_1 info:sqlalchemy.engine.base.engine:() info:sqlalchemy.engine.base.engine:select cast('test collated returns' char character set utf8) collate utf8_bin anon_1 info:sqlalchemy.engine.base.engine:() debug:sqlalchemy.pool.queuepool:connection <_mysql.connection open '******' @ 208f590> checked out pool debug:sqlalchemy.pool.queuepool:created new connection <_mysql.connection open '******' @ 20b45b0> debug:sqlalchemy.pool.queuepool:connection <_mysql.connection open '******' @ 20b45b0> checked out pool info:sqlalchemy.engine.base.engine:begin (implicit) ... info:sqlalchemy.engine.base.engine:commit debug:sqlalchemy.pool.queuepool:connection <_mysql.connection open '******' @ 20b45b0> being returned pool debug:sqlalchemy.pool.queuepool:connection <_mysql.connection open '******' @ 20b45b0> rollback-on-return """
i bind connection session, when commit new object, new connection created , used. why?!
doc:
bind – optional engine or connection session should bound. when specified, sql operations performed session execute via connectable.
Comments
Post a Comment