Re: sqlite3 double quote behavior

2022-12-15 Thread Thomas Passin
There is a Python adapter for SQLITE called "APSW". It has a config() function. I looked in the codebase and it defines the two configuration constants needed to turn off the double quote behavior (see https://sqlite.org/quirks.html). These constants are SQLITE_DBCONFIG_DQS_DDL and

Re: sqlite3 double quote behavior

2022-12-15 Thread John K. Parejko
Thanks for the discussion. I’m aware that SQLite has several different options for identifier quoting, but they’re not cross-compatible with other SQL, whereas double quotes are (modulo this strange SQLite behavior). Is anyone here familiar with the python sqlite3 implementation? I wonder how

Re: sqlite3 double quote behavior

2022-12-13 Thread Roel Schroeven
Chris Angelico schreef op 13/12/2022 om 22:58: Okay, so. exactly the same as if you use standard double quotes, but change the configuration option. So the options are: make everything worse for everyone by exacerbating the problem of non-standard identifier quoting, or get this API so

Re: sqlite3 double quote behavior

2022-12-13 Thread Chris Angelico
On Wed, 14 Dec 2022 at 08:19, Roel Schroeven wrote: > > Chris Angelico schreef op 13/12/2022 om 20:01: > > On Wed, 14 Dec 2022 at 06:00, Roel Schroeven wrote: > > > > > > Stefan Ram schreef op 13/12/2022 om 8:42: > > > > "John K. Parejko" writes: > > > > >I was just burned by this, where some

Re: sqlite3 double quote behavior

2022-12-13 Thread Roel Schroeven
Roel Schroeven schreef op 13/12/2022 om 22:36: sqlite> insert into foo values ("xyzzy", "xyzzy"); SQLite accepts it like that, but I really should have used single quotes there instead of double quotes. It's a bad habit from using MySQL for too long I guess. -- "In the old days, writers used

Re: sqlite3 double quote behavior

2022-12-13 Thread Roel Schroeven
Roel Schroeven schreef op 13/12/2022 om 22:18: Chris Angelico schreef op 13/12/2022 om 20:01: > > 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

Re: sqlite3 double quote behavior

2022-12-13 Thread Roel Schroeven
Chris Angelico schreef op 13/12/2022 om 20:01: On Wed, 14 Dec 2022 at 06:00, Roel Schroeven wrote: > > Stefan Ram schreef op 13/12/2022 om 8:42: > > "John K. Parejko" writes: > > >I was just burned by this, where some tests I’d written > > >against an sqlite database did not fail in the way

Re: sqlite3 double quote behavior

2022-12-13 Thread Chris Angelico
On Wed, 14 Dec 2022 at 06:00, Roel Schroeven wrote: > > Stefan Ram schreef op 13/12/2022 om 8:42: > > "John K. Parejko" 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

Re: sqlite3 double quote behavior

2022-12-13 Thread Roel Schroeven
Stefan Ram schreef op 13/12/2022 om 8:42: "John K. Parejko" 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

Re: sqlite3 double quote behavior

2022-12-13 Thread Roel Schroeven
Op 13/12/2022 om 15:15 schreef Roel Schroeven: +1 to expose the sqlite3_db_config() function, or maybe just a special case for this specific option. Actually I'm surprised SQLite doesn't have a PRAGMA command to customize this behavior. That would make it possible to customize from any

Re: sqlite3 double quote behavior

2022-12-13 Thread Roel Schroeven
Op 13/12/2022 om 14:23 schreef Thomas Passin: On 12/13/2022 4:09 AM, Chris Angelico wrote: On Tue, 13 Dec 2022 at 19:52, Roel Schroeven wrote: Like Lars Liedtke this is not an exact answer to your question, but you can side-step the issue by using parametrized queries, i.e. instead of  

Re: sqlite3 double quote behavior

2022-12-13 Thread Chris Angelico
On Wed, 14 Dec 2022 at 00:30, Thomas Passin wrote: > > On 12/13/2022 4:09 AM, Chris Angelico wrote: > > On Tue, 13 Dec 2022 at 19:52, Roel Schroeven wrote: > >> Like Lars Liedtke this is not an exact answer to your question, but you > >> can side-step the issue by using parametrized queries,

Re: sqlite3 double quote behavior

2022-12-13 Thread Thomas Passin
On 12/13/2022 4:09 AM, Chris Angelico wrote: On Tue, 13 Dec 2022 at 19:52, Roel Schroeven wrote: Like Lars Liedtke this is not an exact answer to your question, but you can side-step the issue by using parametrized queries, i.e. instead of cur.execute('SELECT name, location FROM persons

Re: sqlite3 double quote behavior

2022-12-13 Thread Chris Angelico
On Tue, 13 Dec 2022 at 19:52, Roel Schroeven wrote: > Like Lars Liedtke this is not an exact answer to your question, but you > can side-step the issue by using parametrized queries, i.e. instead of > > cur.execute('SELECT name, location FROM persons WHERE name = "John > Doe"') > > do > >

Re: sqlite3 double quote behavior

2022-12-13 Thread Roel Schroeven
Op 13/12/2022 om 1:41 schreef John K. Parejko: Asking here before I file an improvement request issue on the python GitHub: sqlite has a known misfeature with double-quoted strings, whereby they will be interpreted as string literals if they don’t match a valid identifier [1]. The note in the

Re: sqlite3 double quote behavior

2022-12-13 Thread Lars Liedtke
Hey, this might be not the answer you are searching for at all, and it is only a mitigation. But as far as I know, sqlalchemy (and other ORMs) do that for you. I am mention sqlalchemy, because it has got a query builder as well. So you don't have to change your DB-Layer to full ORM, but you

sqlite3 double quote behavior

2022-12-12 Thread John K. Parejko
Asking here before I file an improvement request issue on the python GitHub: sqlite has a known misfeature with double-quoted strings, whereby they will be interpreted as string literals if they don’t match a valid identifier [1]. The note in the sqlite docs describe a way to disable this