完善功能:数据库超时等待

This commit is contained in:
Qiea
2024-12-22 12:31:29 +08:00
parent 1d534be4c1
commit 5a82462cac
6 changed files with 103 additions and 40 deletions

View File

@@ -61,11 +61,16 @@ class Hash:
_byte_data = bytes.fromhex(str(imagehash.average_hash(_img)))
_cursor = self.conn.cursor()
_cursor.execute("""
INSERT INTO image_hashes (id, hash)
INSERT INTO `{}` (`{}`, `{}`)
VALUES (%s, %s)
ON DUPLICATE KEY UPDATE
hash = VALUES(hash)
""", (_qqnumber, _byte_data))
ON DUPLICATE KEY UPDATE `{}` = VALUES(`{}`)
""".format(
config['mysql']['table_name'],
config['mysql']['id_column_name'],
config['mysql']['hash_column_name'],
config['mysql']['hash_column_name'],
config['mysql']['hash_column_name']
), (_qqnumber, _byte_data))
logging.debug(f'[{_qqnumber}]:{_byte_data}')
self.conn.commit()
_cursor.close()