0

I am trying to insert JSON data into an SQLite3 database table. I'm getting an error:

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

This is the query:

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';

Any ideas what is causing this?

2
  • Is this really your code? This looks strange: "...where where title='TEMPLATE'" I do not think you can double the where keyword. Commented Sep 4, 2015 at 20:14
  • The error message and the query do not match. Use copy+paste to show the exact code that fails. Commented Sep 5, 2015 at 6:45

1 Answer 1

1

I do not think you have posted the correct code. If I fix the double 'where' your code works just fine.

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

>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.