title: Python Flask SQLAlchemy Pagination
body: <p>I am having trouble implementing pagination with Flask-SQLAlchemy or Flask-Pagination, either or. I am unsure how to initialize the pagination, setting pages, determining pages, offest, etc. I am coming from PHP, quite new to Python.</p>
  
  <p>I am querying all the posts in my database</p>
  
  <pre><code>posts = Posts.query.order_by(Posts.time.desc()).all()
  </code></pre>
  
  <p>I have been looking at the following examples:</p>
  
  <ul>
  <li><a href="http://www.ergo.io/tutorials/better-pagination-in-flask/better-pagination-in-flask/" rel="noreferrer">http://www.ergo.io/tutorials/better-pagination-in-flask/better-pagination-in-flask/</a></li>
  <li><a href="https://pythonhosted.org/Flask-paginate/" rel="noreferrer">https://pythonhosted.org/Flask-paginate/</a></li>
  <li><a href="https://stackoverflow.com/questions/6282534/sqlalchemy-pagination">sqlalchemy pagination</a></li>
  </ul>
  
  <p>I am confused on really what to do, the information I am finding greatly differs between articles. It's left me with confusion and not knowing where to begin. I want to query all rows of the database table, limit the results to 20 and paginate. I'm not seeing this clearly.</p>