# Error on INSERT INTO sqlite DB

**URL:** <https://discourse.nodered.org/t/error-on-insert-into-sqlite-db/13872>\
**Category:** General\
**Created:** [31 July 2019 16:17 UTC](https://discourse.nodered.org/t/error-on-insert-into-sqlite-db/13872 "2019-07-31T16:17:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pautorras](https://avatars.discourse-cdn.com/v4/letter/p/c57346/32.png) [@pautorras](https://discourse.nodered.org/u/pautorras)\
**Post date:** [31 July 2019 16:17 UTC](https://discourse.nodered.org/t/error-on-insert-into-sqlite-db/13872/1 "2019-07-31T16:17:37Z")

</div>

Hi,

When I insert some var values in sqlite DB, debug console send me this kind of message:

"Error: SQLITE\_ERROR: near ":12": syntax error"  
"Error: SQLITE\_ERROR: near ":02": syntax error"

In a function i'm trying to insert with this command:

var newMsg = {  
"topic": "INSERT INTO Consums (Data,Hora,GenFotoWL1,ConsumWL1,XarxaWL1,ExcedentWL1,XarxaKwh,FVKwh)"+"VALUES ( "+data+","+hora+","+FOTOV+","+CASA+","+XARXA+","+EXCD+","+XAKWHIII+","+FKWHIII+")"  
}  
return newMsg;

Where data, hora, FOTOV,..., are declarated vars in this function.  
Some fields are text, others are REAL and others INT.

What is the meaning of this error?  
I don't know whats wrong....

Thanks in advance

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [31 July 2019 16:23 UTC](https://discourse.nodered.org/t/error-on-insert-into-sqlite-db/13872/2 "2019-07-31T16:23:33Z")

</div>

Hi @pautorras

the error means you have a syntax error in the SQL statement you are passing the sqlite node.

The best thing to do is to wire a Debug node to your function, configure it to show `msg.topic` and then you can see the actual SQL statement you are passing and see if you can spot what syntax error you have.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [31 July 2019 16:41 UTC](https://discourse.nodered.org/t/error-on-insert-into-sqlite-db/13872/3 "2019-07-31T16:41:12Z")

</div>

Strings need to be enclosed in quotes;

```auto
'"+hora+"'

```
