def find_by_id(self, _id, attempt = 0):
with self.conn.cursor() as cur:
try:
cur.execute(
"""SELECT id FROM page WHERE url = '{}'""".format(_id)
)
return cur.fetchone()
except (psycopg2.IntegrityError, psycopg2.InternalError) as err:
if attempt < 5:
return self.find_by_id(_id, attempt + 1)
else:
raise err
评论列表
文章目录