12-31-2013 06:02 AM
I have found a problem with headless services and was wondering if anyone had any ideas...
Okay I have a headless application written in two parts (a UI app and a service app) both of these apps link to a shared library that implements my data-access layer (using SQLite)
My UI app writes a new record to a table and then notifies my service app via invoke manager to reload it's configuration.
When my service reads it's configuration it fails to find the records that the UI app added.
First of all I thought it was a problem with file access (as the database was stored at ./data/mydatabase.db) but I have since moved it to (./shared/misc/mydatabase.db) to no avail (the UI app has no problem accessing the database whereever it is)
What I am wondering is whether there are limitations on what the headless portion of my application can see? Since it does not have a bar-descriptor of it's own I would have assumed it would inherit the permissions of the main UI app.
Secondly do I need to close the SQLite connection after each CRUD operation to ensure the other app will be able to read? Actually I will give that a go in a moment...
Anyway, any thoughts greatly appreciated.
12-31-2013 07:01 AM
Turns out that it was a problem with SQLite and how it handles BOOLEAN columns.
I have a table that has the following schema (there are more columns but I left those out for brevity)
CREATE TABLE IF NOT EXISTS MyTable (
MyID INTEGER PRIMARY KEY AUTOINCREMENT,
With this table if I issue the following SELECT statement it returns no rows even when I explicitly add rows that would match the query...
SELECT MyId, Enabled, Name FROM MyTable WHERE Enabled=1;
I have also tried
SELECT MyId, Enabled, Name FROM MyTable WHERE Enabled;
SELECT MyId, Enabled, Name FROM MyTable WHERE Enabled=True;
All return zero rows.
Since SQLite does not natively support boolean columns (it does a conversion - apparently to integer) then comparisons to 0 or 1 should work but don't appear to.
Since I use parameter binding during the insert I might try doing parameter binding for the select and see if that works when I get a moment. For now though I just get all the rows and filter manually when I read each row - PITA but it works well enough for me to move onto other parts of this app...