NS_ERROR_FAILURE in SQLite insert

4k views Asked by At

I just bought a Kobo eReader which forces me to register at their website before the eReader functions. Seeing that I'm quite a privacy fundamentalist I refuse to register to read a couple books, so I went searching for an alternative. This brought me to this blogpost, which suggests to open the SQLite DB on the eReader and manually inserting a user with the following insert (formatted for readability):

INSERT INTO user (
    UserID
    ,UserKey
    ,UserDisplayName
    ,UserEmail
    ,___DeviceID
    ,HasMadePurchase
)
VALUES (
    ‘5b8b0d65-b50f-4460-b6df-aca5e64f4882’
    ,’626d73ed-8382-4c1d-9750-cfe741c6e773’
    ,’a_name’
    ,’an_email_address’
    ,’01:23:45:67:89:ab’
    ,’TRUE’
);

So I found the sqlite database and I ran the query, but I get the following error message

SQLiteManager: Likely SQL syntax error: INSERT INTO user(UserID,UserKey,UserDisplayName,UserEmail,___DeviceID,HasMadePurchase) VALUES(‘5b8b0d65-b50f-4460-b6df-aca5e64f4882’,’626d73ed-8382-4c1d-9750-cfe741c6e773’,’a_name’,’an_email_address’,’01:23:45:67:89:ab’,’TRUE’);
[ unrecognized token: "4c1d" ]
Exception Name: NS_ERROR_FAILURE
Exception Message: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [mozIStorageConnection.createStatement]

I looked at the structure of the user table, which is (as you can see below), slightly different from the the query.

CREATE TABLE user (
    UserID TEXT NOT NULL
    ,UserKey TEXT NOT NULL
    ,UserDisplayName TEXT
    ,UserEmail TEXT
    ,___DeviceID TEXT
    ,FacebookAuthToken TEXT                    <= missing from query
    ,HasMadePurchase BIT DEFAULT FALSE
    ,IsOneStoreAccount BIT DEFAULT FALSE       <= missing from query
    ,IsChildAccount BIT DEFAULT FALSE          <= missing from query
    ,PRIMARY KEY (UserID)
)

As you can see there are three columns in the db which are not in the query. I don't think that this is the source of the error though.

Does anybody know what the error means and how I can solve the error? All tips are welcome!

1

There are 1 answers

0
bd33 On BEST ANSWER

Change the single quotes on the VALUES section to double quotes - the error references the middle portion of your string. In addition to that, surround the column values in backticks and then everything works.