sqlite3 double quote behavior

Roel Schroeven roel at roelschroeven.net
Tue Dec 13 13:58:35 EST 2022


Stefan Ram schreef op 13/12/2022 om 8:42:
> "John K. Parejko" <parejkoj at gmail.com> writes:
> >I was just burned by this, where some tests I’d written
> >against an sqlite database did not fail in the way that they
> >“should” have, because of this double-quoted string issue.
>
>    In standard SQL, double quotes denote identifiers that are
>    allowed to contain special characters.
Or that are equal SQL keywords, which can be a reason to double-quote 
them. SQL engines sometimes add new keywords; explicitly marking string 
literals as string literals prevents future conflicts and confusion.

Perhaps it's a better idea to use [identifier] or `identifier` instead 
though (I just learned about those on 
https://sqlite.org/lang_keywords.html). Both are not standard SQL ([] is 
used in MS Access and SQL Server, `` is used in MySQL) but both work in 
SQLite. That should prevent any ambiguity and confusion, if it doesn't 
bother you too much that it's not standard SQL.

-- 
"I love science, and it pains me to think that to so many are terrified
of the subject or feel that choosing science means you cannot also
choose compassion, or the arts, or be awed by nature. Science is not
meant to cure us of mystery, but to reinvent and reinvigorate it."
         -- Robert Sapolsky



More information about the Python-list mailing list