I am writing a bot in Python using sqlite. I want to hide different things in the database. The database supports image storage in BLOB cells. How to throw there, for example * .pdf file and how to get it from there then.
Python 3.5 is used
I am writing a bot in Python using sqlite. I want to hide different things in the database. The database supports image storage in BLOB cells. How to throw there, for example * .pdf file and how to get it from there then.
Python 3.5 is used
import sqlite3 as lite import sys con = lite.connect("test.db") cur = con.cursor() #Загрузка файла в БД file_input = open("blank.pdf", "rb") file = file_input.read() file_input.close() binary = lite.Binary(file) cur.execute("INSERT INTO files(file) VALUES (?)", (binary,) ) con.commit() #Выгрузка файла из БД cur.execute("SELECT file FROM files LIMIT 1") data = cur.fetchone()[0] file_output = open("blank2.pdf","wb") file_output.write(data) file_output.close() con.close() import sqlite3 as lite — this degrades the readability of the code without a reason. - jfsSource: https://ru.stackoverflow.com/questions/614091/
All Articles