SQLite Forum

try to insert dollar sign and percentage chars
Login

try to insert dollar sign and percentage chars

(1) By anonymous on 2021-12-29 01:40:25 [link] [source]

We were trying to insert a text string $0123 into a text column and in sqlite it shows as -bash123

so we were able to escape by putting \ in front of it

\$0123
and it worked

is there a list of all the special chars that need to be escaped in sqlite3 besides the dollar sign ?

(2) By Larry Brasfield (larrybr) on 2021-12-29 01:51:10 in reply to 1 [link] [source]

The conversion of $0 to 'bash' is done by bash. (I don't know where that leading dash might have come from.) This is not done by the sqlite3 shell.

I recommend running 'man bash' or 'info bash' and spending some time reading about variable expansion and other expansions done by the bash shell.

Alternatively, use single-quote on arguments to sqlite3 that you do not want treated as anything but what you typed, unless you need to use single-quote within what is to be passed to sqlite3 on its command tail.

(5) By anonymous on 2021-12-29 01:58:28 in reply to 2 [link] [source]

thank you!

(3) By Simon Slavin (slavin) on 2021-12-29 01:52:26 in reply to 1 [source]

This is a problem with your shell, which I assume is bash, not with SQLite. SQLite has no problem with any character except for the single apostrophe, which is the character used to enclose text. bash uses dollar signs to indicate variables.

(4) By anonymous on 2021-12-29 01:58:09 in reply to 3 [link] [source]

thank you!

(6) By Larry Brasfield (larrybr) on 2021-12-29 02:11:59 in reply to 3 [link] [source]

This is a problem with your shell ...

A large contingent would say it's a feature.

SQLite has no problem with any character except for the single apostrophe, which is the character used to enclose text.

The SQLite shell has its own quoting rules, explained at Rules for "dot-commands" in section 4. Misunderstanding those rules could convert its quoting and unescaping features into problems. More than just the apostrophe character is involved.