What I am trying to do
pdf files are stored in my sqlite3 database as blobs.
I want to select one specific pdf file and save it as a file.
That's my python error message:
sqlite3.OperationalError: Could not decode to UTF-8 column 'dokument' with text '%PDF-1.2
What's my python code
I tried a lot, also copied and paste a lot from the internet. I assume it's less an issue of the code, but more that I forget something on a higher level (e.g. sqlite3 configuration)?
Anyhow: the very latest code I work with:
(remark: I am not a professionel programer, I do this for fun and as a hobby).
pdf files are stored in my sqlite3 database as blobs.
I want to select one specific pdf file and save it as a file.
That's my python error message:
sqlite3.OperationalError: Could not decode to UTF-8 column 'dokument' with text '%PDF-1.2
What's my python code
I tried a lot, also copied and paste a lot from the internet. I assume it's less an issue of the code, but more that I forget something on a higher level (e.g. sqlite3 configuration)?
Anyhow: the very latest code I work with:
def readBlobData_and_safe_as_file(path_to_db, select_query): con = sqlite3.connect(path_to_db) cur = con.cursor() with open("/home/Datei.pdf", "wb") as output_file: cur.execute(select_query) blobdat = cur.fetchone() output_file.write(blobdat[0]) cur.close() con.close()After one week of try-and-error, you can't believe how grateful I would be for support. Millions thanks in advance.
(remark: I am not a professionel programer, I do this for fun and as a hobby).