在mysql数据库中存储Imagehash

2024-05-29 01:32:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用python在mysql数据库中保存hash_值。我已获得哈希值hash = imagehash.dhash(Image.open('temp_face.jpg')),但在执行insert查询cursor.execute("INSERT INTO image(hash,name,photo) VALUES(%d,%s,%s )", (hash,name, binary_image))之后,它给了我错误“Python'imagehash'无法转换为MySQL类型”

| Field   | Type        | Null | Key | Default           | Extra             |
+---------+-------------+------+-----+-------------------+-------------------+
| hash    | binary(32)  | NO   | PRI | NULL              |                   |
| name    | varchar(25) | NO   |     | NULL              |                   |
| photo   | blob        | NO   |     | NULL              |                   |
| arrival | datetime    | NO   |     | CURRENT_TIMESTAMP | DEFAULT_GENERATED |
+---------+-------------+------+-----+-------------------+-------------------+

那么,可以做些什么来存储值,或者是否有其他方法来完成相同的任务


Tags: nonameimage数据库mysqlhashopennull

热门问题