AnkiPandas
AnkiPandas copied to clipboard
Fix Issue #137: Preserve PRIMARY KEY constraints in write()
When using pandas.to_sql(if_exists="replace"), PRIMARY KEY constraints are lost from SQLite tables. This breaks Anki's synchronization mechanism between devices.
Fix
- Reassign
id_columnto be the PRIMARY KEY usingdtype={'id_column': 'INTEGER PRIMARY KEY'}parameter when callingpandas.to_sql()inraw.py - Added simple regression tests covering both
notesandcardstables
Testing
- All existing tests pass
- New regression test
test_primary_key_constraint_preservedvalidates the fix
Changed Files
| File | Status |
|---|---|
I want to note that I did not remove the _override_exception check in collection.py so even if this change is merged, the NotImplementedError will still be raised.