Original title: **Using insert-or-replace sets added_ms and updated_ms to the same value** ---- > [!TIP] > See **[this comment](https://github.com/simonw/sqlite-chronicle/issues/7#issuecomment-2833108867)** for a summary of this issue, it got very long! ---- I just noticed that on this demo: - https://demos.datasette.cloud/data?sql=select+document_number%2C+added_ms%2C+updated_ms%2C+version%2C+deleted+from+_chronicle_documents+where+added_ms+%21%3D+updated_ms - 0 results - From https://demos.datasette.cloud/data/_chronicle_documents and https://demos.datasette.cloud/data/documents That's populated by this script https://github.com/simonw/federal-register-to-datasette/blob/fb848b0e05ff79ca60a9d9d8adb0c9a36a938751/fetch_documents.py which makes this API call: ```python body = { "rows": documents, "replace": True, } req = urllib.request.Request( "https://demos.datasette.cloud/data/documents/-/insert", data=json.dumps(body).encode(), headers=headers, method="POST", ) ``` Which results in a call to the `sqlite-utils` method `.insert_all(..., replace=True)` Which does this: https://github.com/simonw/sqlite-utils/blob/88bd37220593f46ad2221601d6724dd0198400ad/sqlite_utils/db.py#L2983-L2988 ```sql INSERT OR REPLACE INTO documents ... ```
Original title: Using insert-or-replace sets added_ms and updated_ms to the same value
Tip
See this comment for a summary of this issue, it got very long!
I just noticed that on this demo:
That's populated by this script https://github.com/simonw/federal-register-to-datasette/blob/fb848b0e05ff79ca60a9d9d8adb0c9a36a938751/fetch_documents.py which makes this API call:
Which results in a call to the
sqlite-utilsmethod.insert_all(..., replace=True)Which does this: https://github.com/simonw/sqlite-utils/blob/88bd37220593f46ad2221601d6724dd0198400ad/sqlite_utils/db.py#L2983-L2988
INSERT OR REPLACE INTO documents ...