Deck corruption - DBError / InvalidColumnType - 3 - mod - Real

Hi,

I have been using Anki for a long time (mostly on AnkiDroid, but also sometimes on the PC/Linux version), but have been experiencing some DbErrors recently. Some have been fixed by applying the patches in another post about factors, but now I’m stuck with another error:

anki.errors.DBError: DbError { info: "InvalidColumnType(3, \"mod\", Real)", kind: Other }

I also suspect there is a 2038-related bug with dates when I put some cards more than 12 years from now (because yes after some time you reach that kind of level of pushing back on cards you really know by heart), then corruption of the DB looks almost inevitable.

In the meantime, is there any way of restoring the DB as the affected decks are no longer usable at this point?

Thanks a lot in advance!

Is this the other fix you already tried?

If so, what about these other threads? Search results for 'invalidcolumntype order:latest' - Anki Forums

Thanks for the quick reply, the thread I was referring to was the one about “factor”, but for some reason I can’t post links here.

“Check Database” fails with the error:

DbError { info: "InvalidColumnType(3, \"mod\", Real)", kind: Other }

For reference:

Version <U+2068>25.07.5 (7172b2d2)<U+2069>
Python 3.13.5 Qt 6.9.1 Chromium 122

You should be able to post links to other posts, even as a new user. If it’s not working – you can `put it between backticks` (or click “Preformatted text” in the menu bar).

Thanks, I’ll keep that in mind. None of the other threads mention the “mod, Real” that I’m getting so it is probably something different. In any case, the “check database” keeps failing and no matter how much I check/sync/restart I still have the same error, unfortunately.

Have you tried Check Database on another device/install, and forcing the one-way sync from there?

Otherwise, you might try restoring a backup from before the corruption, or more extreme database interventions – Managing Files - Anki Manual .

I guess I’ll try the manual export to file → import back to sqlite. My collection is quite big - many decks each containing many cards (32Mb anki2 file)… so I don’t expect this to be a walk in the park but I may just be too prudent/pessimistic. :slight_smile: I’ll come back here to report when I’m done with that. In any case, thanks for the help so far!

1 Like

Probably caused by an add-on or import putting bad values in your collection. Try the following:

 mw.col.db.execute(“UPDATE notes SET mod = CAST(mod AS INTEGER)”)

Please see Miscellaneous - Anki Manual

If it fixes the problem, you’ll need to force a full upload afterwards.

2 Likes

Thanks, that fixed it! I then proceeded with the DB check which succeeded (reporting 5 fixed errors - but at least it didn’t crash). The whole collection seems to work perfectly fine now, thanks a lot!

NB: I haven’t used any plugin for a long time - and anyway I’m mostly using AnkiDroid.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.