html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,issue,performed_via_github_app https://github.com/simonw/sqlite-utils/issues/344#issuecomment-1815825863,https://api.github.com/repos/simonw/sqlite-utils/issues/344,1815825863,IC_kwDOCGYnMM5sO03H,16437338,2023-11-17T06:44:49Z,2023-11-17T06:44:49Z,CONTRIBUTOR,"hello Simon, I've added more STRICT table support per https://github.com/simonw/sqlite-utils/issues/344#issuecomment-982014776 in changeset https://github.com/simonw/sqlite-utils/commit/e4b9b582cdb4e48430865f8739f341bc8017c1e4. It also fixes table.transform() to preserve STRICT mode. Please pull if you deem appropriate. Thanks!","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",1066474200, https://github.com/simonw/sqlite-utils/issues/344#issuecomment-982076924,https://api.github.com/repos/simonw/sqlite-utils/issues/344,982076924,IC_kwDOCGYnMM46iU38,9599,2021-11-29T22:20:44Z,2021-11-29T22:20:44Z,OWNER,Need to figure out a good pattern for testing this in CI too - it will currently skip the new tests if it doesn't have SQLite 3.37 or higher.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",1066474200, https://github.com/simonw/sqlite-utils/issues/344#issuecomment-982076702,https://api.github.com/repos/simonw/sqlite-utils/issues/344,982076702,IC_kwDOCGYnMM46iU0e,9599,2021-11-29T22:20:22Z,2021-11-29T22:20:22Z,OWNER,"I haven't documented `db.supports_strict` yet (I documented `table.strict`) because there wasn't an obvious section of the documentation for it. I need to remember to document it once I add documentation for the `strict=True` parameter.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",1066474200, https://github.com/simonw/sqlite-utils/issues/344#issuecomment-982049148,https://api.github.com/repos/simonw/sqlite-utils/issues/344,982049148,IC_kwDOCGYnMM46iOF8,9599,2021-11-29T21:40:59Z,2021-11-29T21:40:59Z,OWNER,I'm going to add that as `db.supports_strict`.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",1066474200, https://github.com/simonw/sqlite-utils/issues/344#issuecomment-982048918,https://api.github.com/repos/simonw/sqlite-utils/issues/344,982048918,IC_kwDOCGYnMM46iOCW,9599,2021-11-29T21:40:42Z,2021-11-29T21:40:42Z,OWNER,"Here's a function that detects if `strict` is supported or not: ```python import secrets import sqlite3 def supports_strict_tables(db = None): if db is None: db = sqlite3.connect("":memory:"") try: table_name = 't{}'.format(secrets.token_hex(16)) with db: db.execute(""create table {} (name text) strict"".format(table_name)) db.execute(""drop table {}"".format(table_name)) return True except: return False ```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",1066474200, https://github.com/simonw/sqlite-utils/issues/344#issuecomment-982026918,https://api.github.com/repos/simonw/sqlite-utils/issues/344,982026918,IC_kwDOCGYnMM46iIqm,9599,2021-11-29T21:11:42Z,2021-11-29T21:16:31Z,OWNER,"Made myself a test strict table like so: ```pycon >>> import pysqlite3 >>> conn = pysqlite3.connect(""/tmp/strict-table.db"") >>> conn.execute(""create table foo (id integer primary key, name text, weight real) strict"") >>> cursor = conn.cursor() >>> with conn: ... cursor.execute(""insert into foo (name, weight) values ('Lila', '2.31')"") >>> conn.close() ``` Uploaded that to: https://static.simonwillison.net/static/2021/strict-table.db","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",1066474200, https://github.com/simonw/sqlite-utils/issues/344#issuecomment-982020757,https://api.github.com/repos/simonw/sqlite-utils/issues/344,982020757,IC_kwDOCGYnMM46iHKV,9599,2021-11-29T21:03:34Z,2021-11-29T21:03:34Z,OWNER,"From the STRICT docs: > The SQLite parser accepts a comma-separated list of table options after the final close parenthesis in a CREATE TABLE statement. As of this writing (2021-08-23) only two options are recognized: > > - STRICT > - [WITHOUT ROWID](https://www.sqlite.org/withoutrowid.html) So I think I need to read the `CREATE TABLE` statement from the `sqlite_master` table, split on the last `)`, split those tokens on `,` and see if `create` is in there (case insensitive).","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",1066474200, https://github.com/simonw/sqlite-utils/issues/344#issuecomment-982018304,https://api.github.com/repos/simonw/sqlite-utils/issues/344,982018304,IC_kwDOCGYnMM46iGkA,9599,2021-11-29T21:00:02Z,2021-11-29T21:00:02Z,OWNER,Is there a need for an introspection function for telling if a SQLite table is in strict mode or not? How would that work?,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",1066474200, https://github.com/simonw/sqlite-utils/issues/344#issuecomment-982017994,https://api.github.com/repos/simonw/sqlite-utils/issues/344,982017994,IC_kwDOCGYnMM46iGfK,9599,2021-11-29T20:59:37Z,2021-11-29T20:59:37Z,OWNER,"I'm leaning towards silently ignore if SQLite version doesn't support it. That means that the first time you attempt to use `strict=True` we will need to run a test against the database connection to see what version of SQLite it uses, then cache the result to avoid making the same call again for the same connection.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",1066474200, https://github.com/simonw/sqlite-utils/issues/344#issuecomment-982016594,https://api.github.com/repos/simonw/sqlite-utils/issues/344,982016594,IC_kwDOCGYnMM46iGJS,9599,2021-11-29T20:57:42Z,2021-11-29T20:57:42Z,OWNER,"What should happen if you attempt to use `strict=True` against a SQLite version prior to 3.37.0? An obvious error would be best... but how about silently ignoring it on older versions instead? That would match how we handle `deterministic=True` for registering functions: https://github.com/simonw/sqlite-utils/blob/126703706ea153f63e6134ad14e5712e4bbcb8ae/sqlite_utils/db.py#L372-L380 https://github.com/simonw/sqlite-utils/blob/93c7fd9868fed3193a1732b39bfac539e5812b0b/tests/test_register_function.py#L34-L37 ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",1066474200, https://github.com/simonw/sqlite-utils/issues/344#issuecomment-982014776,https://api.github.com/repos/simonw/sqlite-utils/issues/344,982014776,IC_kwDOCGYnMM46iFs4,9599,2021-11-29T20:55:19Z,2021-11-29T20:55:19Z,OWNER,"There are a few places that the `strict=True` option could go: - `table.create()` and `table.create_table_sql()` - The `Database()` constructor, to turn it on for all created tables - The `.insert()` / `.insert_all()` etc family of methods that can implicitly create tables I'll definitely implement the first one, and likely the second one too. I'm on the fence with regards to the third one.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",1066474200, https://github.com/simonw/sqlite-utils/issues/344#issuecomment-982006544,https://api.github.com/repos/simonw/sqlite-utils/issues/344,982006544,IC_kwDOCGYnMM46iDsQ,9599,2021-11-29T20:44:37Z,2021-11-29T20:48:43Z,OWNER,"This worked: ``` cd /tmp mkdir sqlite-3.37 cd sqlite-3.37 wget 'https://www.sqlite.org/2021/sqlite-amalgamation-3370000.zip' unzip sqlite-amalgamation-3370000.zip git clone https://github.com/coleifer/pysqlite3/ cp sqlite-amalgamation-3370000/sqlite3.[ch] pysqlite3 cd pysqlite3 python3 setup.py build_static build bdist_wheel ``` This gave me a file here: ``` pysqlite3 % ls -l dist total 1872 -rw-r--r-- 1 simon wheel 956557 Nov 29 12:38 pysqlite3-0.4.6-cp39-cp39-macosx_10_15_x86_64.whl ``` That wheel only works when installed for Python 3.9 (it failed to install in a Python 3.10 virtual environment) - but `pip install /tmp/sqlite-3.37/pysqlite3/dist/pysqlite3-0.4.6-cp39-cp39-macosx_10_15_x86_64.whl` gave me a working `pysqlite3` - and the following worked: ```pycon >>> import pysqlite3 >>> pysqlite3.connect("":memory:"").execute(""select sqlite_version()"").fetchall() [('3.37.0',)] ``` And if I install `sqlite-utils` in the same virtual environment this works: ``` % sqlite-utils memory 'select sqlite_version()' [{""sqlite_version()"": ""3.37.0""}] ```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",1066474200, https://github.com/simonw/sqlite-utils/issues/344#issuecomment-981999025,https://api.github.com/repos/simonw/sqlite-utils/issues/344,981999025,IC_kwDOCGYnMM46iB2x,9599,2021-11-29T20:34:38Z,2021-11-29T20:35:58Z,OWNER,"I'm going to build my own `pysqlite3` wheel with the latest SQLite to try this out, following the instructions on https://github.com/coleifer/pysqlite3","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",1066474200, https://github.com/simonw/sqlite-utils/issues/344#issuecomment-981997973,https://api.github.com/repos/simonw/sqlite-utils/issues/344,981997973,IC_kwDOCGYnMM46iBmV,9599,2021-11-29T20:33:52Z,2021-11-29T20:33:52Z,OWNER,"From that page: > If you try to open a database containing the STRICT keyword in an earlier version of SQLite, it will not recognize the keyword and will report an error (except as noted below. > > [...] > > Because of a quirk in the SQL language parser, versions of SQLite prior to 3.37.0 can still read and write STRICT tables if they set ""PRAGMA writable_schema=ON"" immediately after opening the database file, prior to doing anything else that requires knowing the schema.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",1066474200,