Jump to content
News about the LabVIEW Wiki! Read more... ×
Sign in to follow this  
Ramesh

SQLite error "Unable to open the database file"

Recommended Posts

Hi,

I am getting error from SQLite while reading the database file. Error is
"Unable to open database file". I am using SQLite from last 1 month and didnt
encouter this error before. Suddenly, from yesterday SQLite is started giving
this error and is random.

What could be the resolution? Please find attached herewith my example code and
the SQLite error

SQLite error.zip

Share this post


Link to post
Share on other sites

I notice that you reopen the DB file on each query.   If you instead opened the file once on initialization, then you'll be less affected by an intermittent file access problem.

The issue might be anti-virus software, or some other software that trolls through files for some reason, temporarily locking them.   Has any such software been added?  

Share this post


Link to post
Share on other sites
On 1/26/2018 at 1:10 AM, drjdpowell said:

I notice that you reopen the DB file on each query.   If you instead opened the file once on initialization, then you'll be less affected by an intermittent file access problem.

The issue might be anti-virus software, or some other software that trolls through files for some reason, temporarily locking them.   Has any such software been added?  

Yes, definitely i will modify the code for to open the file at initialization.

I have not added any such software which could lock the file. I am using ESET NOD32 antivirus software and is running from past 3 years. I am not getting any error while writing the same file and i am using same file from past 3 months to store the database records. The example codes provided with sqlite toolkit also runs without any error.

I am getting errors while opening the file only. To try the locking possibility, i created several files with the same name. The labview code (as given in previous attachment) worked sucessfully on first 2-3 attempts and later started reporting the same error. am i missing something to add in the code? or can you please check the database file, wheather it is locked. Please refer the attachment for database file as well as my previous attachments) 

SQLite error.zip

Share this post


Link to post
Share on other sites

Comments:

1) that error is what you get if your path-to-the-db is wrong.   You are opening read-only, so it will fail if the db file does not exist at that path.  So I suspect your path generation code is wrong.  When I fixed it up I could then open the file.  I opened it multiple times without error.

2) Your Query control was empty, and your various SQL constants referenced columns that don’t exist.  I had to make up a new SELECT statement.

3) You can’t use dates in the format day-month-year and select on it, as alphabetical sorting is not time-sorted.   I set your Start and End times as 01/01/2000 and 31/12/1999 and got every one of your records.  Use ISO-8601 format (year-month-day).   I advise you use the inbuilt support for Timestamps as Text (Bind Timestamp(Text), and Get Column Timestamp).  Use Timestamps, not separate fields for Date and Time.

4) I used SQLite Expert Personal to test and inspect your db file.  You can use this to aid debugging, as you can use it to build and test your SQL before copying to LabVIEW.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using this site, you agree to our Terms of Use.