ITADN

Fix Issue #137: Preserve PRIMARY KEY constraints in write()

#172Pull Requestautoelk 创建于 2025-09-24
A
autoelkcommented
When using `pandas.to_sql(if_exists="replace")`, PRIMARY KEY constraints are lost from SQLite tables. [This breaks Anki's synchronization mechanism between devices.](https://github.com/klieret/AnkiPandas/issues/137#issuecomment-1756625536) ### Fix - Reassign `id_column` to be the PRIMARY KEY using `dtype={'id_column': 'INTEGER PRIMARY KEY'}` parameter when calling `pandas.to_sql()` in `raw.py` - Added simple regression tests covering both `notes` and `cards` tables ### Testing - All existing tests pass - New regression test `test_primary_key_constraint_preserved` validates the fix
合并状态:未合并 2 条评论