cursor.execute('INSERT INTO notes (id, file) VALUES(0, ?)', [sqlite3.Binary
    (ablob)])
conn.commit()
with open('Output.bin', 'wb') as output_file:
    cursor.execute('SELECT file FROM notes WHERE id = 0')
ablob = cursor.fetchone()
output_file.write(ablob[0])
cursor.close()
conn.close()
Writing blob from SQLite to file using Python