user image

Shilpa
Published in : 2022-03-01

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

General

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

Comments

Rakshit Date : 2022-03-02

Best answers

34

Best answers

34

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

Unable to Connect AWS EC2 Instance with my subdirectory through domain registrar.
Publish date: 2022-02-25 | Comments: 2

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

How to checkout to new created branch on bitbucket
Publish date: 2022-03-03 | Comments: 1

Tag: General

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

Tag: General

Is it possible to git commit files without adding a message or comments?
Publish date: 2022-03-02 | Comments: 2

Tag: General

Select from a query with peewee
Publish date: 2022-03-05 | Comments: 0

Tag: General

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

Tag: General