title: How to close a SQLAlchemy session?
body: <p>Following what we commented in <a href="https://stackoverflow.com/questions/8645250/how-to-close-sqlalchemy-connection-in-mysql/8705750?noredirect=1#comment32872652_8705750">How to close sqlalchemy connection in MySQL</a>, I am checking the connections that SQLAlchemy creates into my database and I cannot manage to close them without exiting from Python.</p>
  
  <p>If I run this code in a python console, it keeps the session opened until I exit from python:</p>
  
  <pre><code>from sqlalchemy.orm import sessionmaker
  from models import OneTable, get_engine
  
  engine = get_engine(database="mydb")
  session = sessionmaker(bind=engine)()
  
  results = session.query(OneTable.company_name).all()
  
  # some work with the data #
  
  session.close()
  </code></pre>
  
  <p>and the only workaround I found to close it is to call <code>engine.dispose()</code> at the end.</p>
  
  <p>As per the comments in the link I gave above, my question are now:</p>
  
  <ul>
  <li>Why is <code>engine.dispose()</code> necessary to close sessions?</li>
  <li>Doesn't <code>session.close()</code> suffice?</li>
  </ul>