You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
941 B

2 years ago
  1. from be.model import store
  2. class DBConn:
  3. def __init__(self):
  4. self.conn = store.get_db_conn()
  5. def user_id_exist(self, user_id):
  6. cursor = self.conn.execute("SELECT user_id FROM user WHERE user_id = ?;", (user_id,))
  7. row = cursor.fetchone()
  8. if row is None:
  9. return False
  10. else:
  11. return True
  12. def book_id_exist(self, store_id, book_id):
  13. cursor = self.conn.execute("SELECT book_id FROM store WHERE store_id = ? AND book_id = ?;", (store_id, book_id))
  14. row = cursor.fetchone()
  15. if row is None:
  16. return False
  17. else:
  18. return True
  19. def store_id_exist(self, store_id):
  20. cursor = self.conn.execute("SELECT store_id FROM user_store WHERE store_id = ?;", (store_id,))
  21. row = cursor.fetchone()
  22. if row is None:
  23. return False
  24. else:
  25. return True