Write file from BLOB mysql python
问题 I'm trying to get a file from a database and write it to disk. The file is stored as BLOB. Now I have the following code: #!/usr/bin/python import MySQLdb db2 = MySQLdb.connect(host="localhost", user="root", passwd="root", db="digit") cur = db2.cursor() #get the name of the file cur.execute("SELECT Name FROM ContentFiles WHERE ID=3") nombre = cur.fetchone() #open file and write into. with open(nombre[0],"wb") as output_file: cur.execute("SELECT File FROM ContentFiles WHERE ID=3") ablob = cur