将blob/image转换为image不需要cv2,只需要将blob/image存储在磁盘上并显示出来。下面是从mysql blob到磁盘文件的检索示例。。在
祝你好运!在
引用的页面URL:URLimport mysql.connector
from mysql.connector import Error
def write_file(data, filename):
# Convert binary data to proper format and write it on Hard Disk
with open(filename, 'wb') as file:
file.write(data)
def readBLOB(emp_id, photo, bioData):
print("Reading BLOB data from python_employee table")
try:
connection = mysql.connector.connect(host='localhost',
database='python_db',
user='pynative',
password='pynative@#29')
cursor = connection.cursor()
sql_fetch_blob_query = """SELECT photo from python_employee where id = %s"""
cursor.execute(sql_fetch_blob_query, (emp_id,))
record