user image

Published in : 2022-03-01

SQLite3 Query: Unable to escape string with single quote characters while inserting into table.


I am using sqlite3 and created tables for the hybrid mobile applications. While executing insert query, it shows below error.

SQL error near line 16: near "s": syntax error

the line is,

INSERT INTO table_name (id, fullname) VALUES (98765, 'Robert O\'neils');

The issue is about escape character for a single quote. 

I also tried double escaping the single quote (using \\\' instead of \' ), but that ain't work either. 

What did I miss?


#sqlite #database


Rakshit Date : 2022-03-02

Best answers


Best answers


Mysql syntax: Working sqlfiddle, Replace single quote with single backward slash ("\") as given below.

INSERT INTO mytable values('98765','Robert O\'neils');


Sqlite syntax: Working sqlfiddle, Replace a single quote with another single quote.

INSERT INTO table_name (id, fullname) VALUES (98765, 'Robert O''neils');

Shilpa Date : 2022-03-02

Understood, the syntax is different in it! I see!

Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

Keycloak db query in source codes [closed]
Publish date: 2022-03-05 | Comments: 0

Tag: General

Is there any port I need to allow in google VM instances to allow SMTP?
Publish date: 2022-02-14 | Comments: 1

Tag: General

git issue, fatal error: your current branch appears to be broken
Publish date: 2022-03-01 | Comments: 2

Tag: General

Searching for free live chat service
Publish date: 2022-02-11 | Comments: 2

Tag: General

Convert Stored Procedure of Oracle to SQL Server
Publish date: 2022-03-02 | Comments: 1

Tag: General

Difference between frontend and backend user authentication
Publish date: 2022-02-12 | Comments: 2

Tag: General

Password authentication is temporarily disabled as part of a brownout.
Publish date: 2021-07-28 | Comments: 2

Tag: General

How do i r etrieve users?
Publish date: 2022-03-04 | Comments: 0

Tag: General