Jump to content

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

Link to comment

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?  

Link to comment
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

Link to comment

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.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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