SQLite插入中的NS_ERROR_FAILURE [英] NS_ERROR_FAILURE in SQLite insert

查看:143
本文介绍了SQLite插入中的NS_ERROR_FAILURE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚购买了Kobo电子书阅读器,这迫使我在电子书阅读器运行之前先在其网站上注册.鉴于我是一个非常隐私的原教旨主义者,因此我拒绝注册来阅读几本书,因此我开始寻找替代方法.这使我进入了此博客文章,该文章建议在电子阅读器上手动打开SQLite数据库使用以下插入内容(为便于阅读而格式化)插入用户:

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’
);

所以我找到了sqlite数据库并运行了查询,但收到以下错误消息

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]

我查看了user表的结构(如下所示),它与查询略有不同.

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!

推荐答案

将VALUES部分的单引号更改为双引号-错误引用了字符串的中间部分. 除此之外,将列值放在反引号中,然后一切正常.

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.

这篇关于SQLite插入中的NS_ERROR_FAILURE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆