cool_query.py 459 B

123456789101112131415
  1. import model
  2. from client_controller import _my_tabulate
  3. model.connect()
  4. model.cursor.execute('''
  5. EXPLAIN QUERY PLAN
  6. DELETE FROM sessions
  7. WHERE
  8. (SELECT COUNT(*) as newer
  9. FROM sessions s2
  10. WHERE user_id = s2.user_id
  11. AND rowid < s2.rowid) >= 10
  12. '''.replace('?','1'))
  13. print(_my_tabulate(model.cursor.fetchall(),tablefmt='pipe'))