Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everyone,

Hope all of you are safe.

I wondering if somebody has already came across a way to store huge text file as blob field type in an sqlite table in c++ ?

If somebody has an idea or a hint, please let me know.
Thank you very much in advance.
Have a great day.

What I have tried:

I am currently reading the entire text file and store it via the xxx_bind_xxx method but I am wondering what will happen if I have to deal with a huge text file ?

I have not found a way to write to the blob buffer sequentially but maybe is there another way ?
Posted
Updated 5-Aug-20 17:43pm
Comments
KarstenK 6-Aug-20 2:24am    
as Garth wrote the correct way is to store a file somewhere else and only store the file name with path components in the database.

1 solution

huge ? text ?? you don't supply numbers so a fully qualified answer may be hard

1) subject to this Implementation Limits For SQLite[^] ie 'limits', you may be able to 'zip' compress your file then insert it into a blob

- I'd suggest you write two functions or methods, storeFileAsZip retrieveFileAsZip that wrap the required functions, and maybe give you a stream back in the retrieve case

2) If your compressed (zipped) files are larger than 'blob' max size, you could use a different storage for the files and store the path / access method in the database

You may be able to glean more info/use Namespace Poco::Data[^] to help you.

Btw ..if you're going to store a file in a blob, I'd also include a 'checksum' of the original file, so you can verify integrity etc
 
Share this answer
 
Comments
SuperMiQi 6-Aug-20 5:33am    
Thank you very much for your inputs.
Have a splendid day and stay safe.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900