title: Dumping SQLAlchemy output to JSON
body: <p>I have written a small python script that uses SQLAlchemy to read all records of the db. Here is some of the code</p>
  
  <pre><code>Base=declarative_base()
  Session = sessionmaker(bind=engine)
  cess=Session()
  
  class Test(Base):
       __tablename__ = 'test'
       my_id = Column(Integer, primary_key=True)
       name = Column(String)
       def __init__(self, id, name):
           self.my_id = id
           self.name = name
       def __repr__(self):
          return "&lt;User('%d','%s')&gt;" % (self.id, self.name)
  
  
  
  query= cess.query(Test.my_id, Test.name).order_by(Test.my_id).all()
  </code></pre>
  
  <p>Now the query object i want to convert to a json string. How can i do this ? using json.dumps(query) throws an exception ? </p>
  
  <p>Kind Regards</p>