old_contents: from datetime import date
  from . import db
  
  
  def get_post_list(count=10, start=len(db)):  # generator
      """Yeild a list of posts
  
      :returns: array[post()]
      """
      if start == 0:
          return
      while count > 0 and start > 0:
          post = db.get(eid=start)
          if post is not None:
              post.update({'eid': start})
              count -= 1
              yield post
          start -= 1
  
  
  def get_post(eid):
      return db.get(eid=eid)
  
  
  def add_post(request):
      """Add a post to posts TinyDB
  
      :returns: '', 204 (No Content)
      """
      post = request.get_json()
      today = date.today()
      post_template = {key: post[key] for key in ('post', 'title')}  # proxy dict
      post_template.update(year=today.year, month=today.month)
      return db.insert(post_template)
  
  
  def update_post(eid, request):
      post = request.get_json()
      return db.update(lambda entry: entry.update(post), eids=(eid,))[0]
  
  
  def delete_post(eid):
      return db.remove(eids=(eid,))
  
new_contents: from . import db_cursor, db
  
  
  def get_post_list(count=10, start=-1):  # generator
      """Yeild a list of posts
  
      :returns: generator(post, [post...])
      """
      if start == -1:
          start = db_cursor.execute("SELECT COUNT(*) FROM posts").fetchone()[0]
      if start == 0:
          return  # no posts in database
      for post in db_cursor.execute(
              """SELECT * FROM posts ORDER BY eid DESC LIMIT ?""", (count, )):
          yield dict(zip(('eid', 'title', 'post'), post))
  
  
  def get_post(eid):
      return dict(
          zip(('eid', 'title', 'post'), db_cursor.execute(
              """SELECT * FROM posts WHERE id = ?""", (eid,))))
  
  
  def add_post(request):
      """Add a post to posts table
  
      :returns: int:new_post_eid
      """
      post = request.values.to_dict()
      db_cursor.execute("""
          INSERT INTO posts (title, post)
          VALUES (?,?)
          """, (post['title'], post['post']))
      db.commit()
      return db_cursor.execute("SELECT COUNT(*) FROM posts").fetchone()[0]
  
  
  def update_post(eid, request):
      post = request.get_json()
      db_cursor.execute("""
          UPDATE posts
          SET
              title=?
              post=?
          WHERE eid=?
              """, (post['title'], post['post'], eid))
      return eid
  
  
  def delete_post(eid):
      db_cursor.execute("""DELETE FROM posts WHERE eid = ?""", (eid,))
      return eid
  
subject: change tinydb queries to sqlite3