title: Sqlalchemy flush and commit for ORM objects and mysql metadata locks
body: <p>When I am querying the ORM object with no commits or flush and then trying to truncate the table I am getting <code>metadata lock</code> in DB.</p>
  <p>I am assuming that the <code>session.query(OBJ).all()</code> it's a DQL command and <code>SELECT</code> has shared lock only when the transaction is in progress and the problem seems that I am misunderstanding the root cause of this problem (For now I think that I am starting shared lock with select statement and until I commit my changes I'll have this issue).</p>
  <p>What I did to check how it works:</p>
  <pre><code>s = sessionmaker(bind=engine, autocommit=Fasle, autoflush=False)
  session = s()
  session.query(OBJECT).all()
  time.sleep(100)
  </code></pre>
  <p>And in the second terminal I've run:</p>
  <pre><code>s = sessionmaker(bind=engine, autocommit=Fasle, autoflush=False)
  session = s()
  session.execute('TRUNCATE table OBJECT.__tablename__')
  session.commit()
  </code></pre>
  <p>And I see <code>Waiting for table metadata lock</code> in my process list. Can somebody point me in the right direction or explain why commit is required to this kind of select?</p>