NS_ERROR_FAILURE in SQLite insert

耗尽温柔 提交于 2019-12-24 03:41:02

问题


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:


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.



来源:https://stackoverflow.com/questions/27025578/ns-error-failure-in-sqlite-insert

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!