sqlite
  • sqlite3
  • 2015-09-04 181 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 
    

    >

    相關問題