Python Forum
ZIP file in Sqlite3 database
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ZIP file in Sqlite3 database
#1
Hi guys,

I want to convert a ZIP file into binary through Python so I can put in a Sqlite3 database with the type BLOB. I have Googled how you do this but I only found this

https://pynative.com/python-sqlite-blob-...ital-data/

But this doesn't seem to work for ZIP, right?

I would be grateful if anyone could help
Reply
#2
What makes you think it won't work? Have you tried it?

It is assumed that some other tool will know how to use the BLOB and the database's responsibility begins with storage and ends wit associating the BLOB with a key. The database is not expected to know the structure or content of the BLOB and is not expected to search the BLOB. I see no reason why you couldn't store the contents of a zip file as a BLOB.
Reply
#3
I don't want to store the contents. I want to store the actual Zip file

ZipFile doesn't support rb.
Reply
#4
You appear to think a zip file is somehow different than other files. It is not. It is a bunch of binary data in a format that can be understood by a zip program. If you store a zip file in your database it ceases being a file and becomes a BLOB. The binary data doesn't change. THe format doesn't change. It just moved to a new locale and no longer has a filename or a path. You can turn it back into a file by writing the BLOB to a file.

What we call files are really nothing more than BLOBs in a database we call the file system.
Reply
#5
I've figured it out!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Create SQLite3 database with peewee Jim53_1980 2 600 Dec-20-2023, 02:38 PM
Last Post: buran
  Regex replace in SQLite3 database WJSwan 1 749 Dec-04-2023, 05:55 PM
Last Post: Larz60+
  Rows not adding to sqlite3 database using SQLAlchemy Calab 11 1,597 Jun-02-2023, 05:53 PM
Last Post: bowlofred
  Basic SQL query using Py: Inserting or querying sqlite3 database not returning data marlonbown 3 1,304 Nov-08-2022, 07:16 PM
Last Post: marlonbown
  Python Variables and Sqlite3 Database Staples200 1 3,092 May-25-2021, 02:40 AM
Last Post: Staples200
  how do i store then call a mp3 from sqlite3 .db file gr3yali3n 3 5,635 Dec-11-2020, 10:28 AM
Last Post: snippsat
  sqlite3 database problem Maryan 2 2,427 Oct-05-2020, 05:21 AM
Last Post: buran
  sqlite3 database does not save data across restarting the program SheeppOSU 1 3,405 Jul-24-2020, 05:53 AM
Last Post: SheeppOSU
  Importing data from a text file into an SQLite database with Python macieju1974 7 4,013 Jun-29-2020, 08:51 PM
Last Post: buran
  Trying to send input from html form to database SQLite3 RonnyGiezen 3 61,031 Dec-21-2019, 02:09 PM
Last Post: ibreeden

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020