sqlite
  • sqlite3
  • 2015-09-04 139 views 0 likes 
    0

    我试图将JSON数据插入到SQLite3数据库表中。我发现了一个错误:无法将JSON数据插入到数据库表中

    Error: near line 1: unrecognized token: "1d" 
    

    这是查询:

    update dashboard set data= 
    '{"annotations":{"list":[]},"editable":true,"hideControls":false,"id":30, 
    "nav":[{"collapse":false,"enable":true,"notice":false,"now":false, 
    "refresh_intervals":["5s","10s","30s","1m","5m","15m","30m","1h","2h","1d"], 
    "status":"Stable", 
    "time_options":["5m","15m","1h","6h","12h","24h","2d","7d","30d"],"type":"timepicker"}]}' 
    where where title='TEMPLATE'; 
    

    任何想法是什么原因造成的?

    +0

    这真的是你的代码?这看起来很奇怪:“... where where title ='TEMPLATE'”我不认为你可以将where关键字加倍。 – ravenspoint

    +0

    错误消息和查询不匹配。使用复制+粘贴来显示失败的确切代码。 –

    回答

    1

    我不认为你发布了正确的代码。如果我修复了双“在哪里”,你的代码工作得很好。

    C:\Users\James>sqlite3 test 
    SQLite version 3.8.3.1 2014-02-11 14:52:19 
    Enter ".help" for instructions 
    Enter SQL statements terminated with a ";" 
    sqlite> create table dashboard (data, title); 
    sqlite> .schema 
    CREATE TABLE dashboard (data, title); 
    sqlite> insert into dashboard ("test","TEMPLATE"); 
    sqlite> update dashboard set data= 
        ...> '{"annotations":{"list":[]},"editable":true,"hideControls":false,"id":30, 
        ...> "nav":[{"collapse":false,"enable":true,"notice":false,"now":false, 
        ...> "refresh_intervals":["5s","10s","30s","1m","5m","15m","30m","1h","2h","1d"], 
        ...> "status":"Stable", 
        ...> "time_options":["5m","15m","1h","6h","12h","24h","2d","7d","30d"],"type":"timepicker"}]}' 
        ...> where where title='TEMPLATE'; 
    Error: near "where": syntax error 
    sqlite> update dashboard set data= 
        ...> '{"annotations":{"list":[]},"editable":true,"hideControls":false,"id":30, 
        ...> "nav":[{"collapse":false,"enable":true,"notice":false,"now":false, 
        ...> "refresh_intervals":["5s","10s","30s","1m","5m","15m","30m","1h","2h","1d"], 
        ...> "status":"Stable", 
        ...> "time_options":["5m","15m","1h","6h","12h","24h","2d","7d","30d"],"type":"timepicker"}]}' 
        ...> where title='TEMPLATE'; 
    sqlite> select * from dashboard; 
    {"annotations":{"list":[]},"editable":true,"hideControls":false,"id":30, 
    "nav":[{"collapse":false,"enable":true,"notice":false,"now":false, 
    "refresh_intervals":["5s","10s","30s","1m","5m","15m","30m","1h","2h","1d"], 
    "status":"Stable", 
    "time_options":  ["5m","15m","1h","6h","12h","24h","2d","7d","30d"],"type":"timepicker"}]}|TEMPLATE 
    

    >

    相关问题