title: How can I select all rows with sqlalchemy?
body: <p>I am trying to get all rows from a table.</p>
  
  <p>In controller I have: </p>
  
  <pre class="lang-python prettyprint-override"><code>meta.Session.query(User).all()
  </code></pre>
  
  <p>The result is <code>[, ]</code>, but I have 2 rows in this table.</p>
  
  <p>I use this model for the table:</p>
  
  <pre class="lang-python prettyprint-override"><code>import hashlib
  import sqlalchemy as sa
  from sqlalchemy import orm
  
  from allsun.model import meta
  
  t_user =  sa.Table("users",meta.metadata,autoload=True)
  
  class Duplicat(Exception):
      pass
  class LoginExistsException(Exception):
      pass
  class EmailExistsException(Exception):
      pass
  </code></pre>
  
  <p>And next, in the same file:</p>
  
  <pre class="lang-python prettyprint-override"><code>class User(object):
      def loginExists(self):
          try:
              meta.Session
                  .query(User)
                  .filter(User.login==self.login)
                  .one()
          except orm.exc.NoResultFound:
              pass
          else:
              raise LoginExistsException()
  
      def emailExists(self):
          try:
              meta
                  .Session
                  .query(User)
                  .filter(User.email==self.email)
                  .one()
          except orm.exc.NoResultFound:
              pass
          else:
              raise EmailExistsException()
  
  
      def save(self):
          meta.Session.begin()
          meta.Session.save(self)
          try:
              meta.Session.commit()
          except sa.exc.IntegrityError:
              raise Duplicat()
  
  orm.mapper(User, t_user)
  </code></pre>