how to set autocommit = 1 in a sqlalchemy.engine.Connection

后端 未结 5 2168
旧巷少年郎
旧巷少年郎 2021-02-20 00:01

In sqlalchemy, I make the connection:

 conn = engine.connect()

I found this will set autocommit = 0 in my mysqld log. Now I want to set autocom

5条回答
  •  臣服心动
    2021-02-20 00:15

    In case you're configuring sqlalchemy for a python application using flask / django, you can create the engine like this:

    # Configure the SqlAlchemy part of the app instance
    app.config['SQLALCHEMY_DATABASE_URI'] = conn_url
    
    
    session_options = {
        'autocommit': True
    }
    
    # Create the SqlAlchemy db instance
    db = SQLAlchemy(app, session_options=session_options)
    

提交回复
热议问题