SqlAlchemy

Pylons

db=model.session_context.current.connect()

Newer versions of pylons:

db=model.Session.connection()

Turbogears

db=session.context.current.connect()

From either of the above you can now access queries

q = db.execute('select * from User')
for r in q.fetchmany(5):
  print r