MS SQL files are recorded in MySQL BLOB fields. How can I transfer this data to the user without intermediate storage? That is, probably using io.BytesIO.

# пусть переменная bin_data содержит двоичные данные из ячейки (BLOB) таблицы buffer = io.Bytes() buffer.write(bin_data) 

Then the user must send a link or a request to save the file in Excel format containing this data to the browser.

  • What (which library) do you use to transfer? - m9_psy
  • This whole system is a Bottle project. - Skotinin
  • read the documentation for the bottle - you need to create an HTTPResponse object, transfer the file-like object as the body (body), and of course set the response headers (mimetype, etc.) - whintu
  • And you can link to this item of documentation. - Skotinin

1 answer 1

If you want the browser to upload it to disk instead of displaying data, you can send a Content-Disposition http header with the attachment value :

 #!/usr/bin/env python from bottle import route, run, response # fades.pypi @route('/') def index(): response.content_type = ( # set mime type for .xlsx 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') response.headers['Content-Disposition'] = ( 'attachment; filename=blob.xlsx;' " filename*=utf-8''%D0%B1%D0%BB%D0%BE%D0%B1.xlsx") return bin_data run(host='localhost', port=24303) 

Here is the documentation for the bottle.response object .