完善功能:数据库超时等待
This commit is contained in:
13
Tools.py
13
Tools.py
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user