From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SQLite db file lost table after read and write as text file.

Solved!
Go to solution

I am thinking about encrypt my SQlite file (without using extension tool) by reading db file as text file (using Read from Text File vi) then encrypt this text content and write back as text file (using Write to Text File vi). By some reason, I cannot access to the table of the db file after decrypting. Because of that reason, I tried is to read db file then rewrite immediately as a new text file. The result is I cannot access to the table anymore (similar to original issue). I tried to use SQLite Studio to access the original file and the new rewrite file. I attach the image of the original and the rewritten text file opened in SQLite Studio. The text content of both files are similar.

 

Anyone try to do this with successful please give me some advice, otherwise please let me know what wrong with my solution.

 

Thank you in advance.

0 Kudos
Message 1 of 13
(3,257 Views)
Solution
Accepted by topic author NTT

Of course not! A db file is not a text file, so treating it as one will cause trouble. The Read from Text File and Write to Text File does line ending transformation. It is not meant to maintain the binary integrity of a file but the textual integrity, two very different things. Use Read from Binary File and Write to Binary file instead. They will not do line ending transformations!

Rolf Kalbermatter
My Blog
Message 2 of 13
(3,221 Views)

Thanks Rolf for replying.

I have just tried to replaced read and write text file with read and write binary file but it still does not work. I tried to read back both files back and compare them either as text or binary and they are all equal. In case of using binary read/write it shows the db file is SQLite ver 2 now.

 

 

0 Kudos
Message 3 of 13
(3,217 Views)

Thanks Rolfk.

What you said is actually correct. I have just made mistake when using read/write binary file incorrectly.

I updated the copy content for future ref.

0 Kudos
Message 4 of 13
(3,205 Views)

I always thought that you could safely use the text file VIs with binary data if you unchecked the "convert eol" option.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 13
(3,203 Views)

Bill,

I just checked but I don't see where to unchecked the "convert eol" option. What vi you talked about?

 

Regards

0 Kudos
Message 6 of 13
(3,198 Views)

Well, right click on the Read/Write Text File VI and deselect the Convert EOL option.

 

I'm not sure if disabling this option really is enough, but it sounds anyways wrong to use that if there is a dedicated binary version.

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 13
(3,191 Views)

Maybe we have different definitions of "binary".  I think what I actually mean by "binary" is "raw" data.  Binary, as it is defined in the Binary file functions, means some kind of structured data that isn't text.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 13
(3,186 Views)

Rolk,

With this option the compare returns the same but I cannot add the db file to SQLite Studio. Not sure why.

0 Kudos
Message 9 of 13
(3,181 Views)

@NTT wrote:

Rolk,

With this option the compare returns the same but I cannot add the db file to SQLite Studio. Not sure why.


I would actually suggest trying your old code with the "Convert EOL" option unchecked.  It seems to be the easy thing to try.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 10 of 13
(3,169 Views)