The database’s structure used to be documented by AnkiDroid at: https://github.com/ankidroid/Anki-Android/wiki/Database-Structure (and not by the main Anki project, as far as I’m aware).
It looks like the database schema has changed completely (somewhere between 2.1.13 and 2.1.28, i.e. on a “patch version”?): for instance, “SELECT decks FROM col” doesn’t return a JSON containing information about the decks anymore, but an error. Instead, the information seems to be in a “decks” table.
Is this documented anywhere? If it is, it doesn’t look like Google has noticed it, and I couldn’t find it in the manual
Where possible I recommend accessing the database via libanki, as it insulates you from the actual database layout. If you can’t do that, you’ll either need to update your code using Anki’s source as a guide, use the downgrade button, or export your collection to get a copy in an older schema version.
Oh, my use case is very simple and requires 2 simple queries (find deck ids based on deck names, and find cards in those decks), so I’ve managed to adapt the first one in a few minutes of looking around, but I was of course wondering if there was some documentation.
Is there a documentation of libanki, too? When I wrote those programs, I remember it seemed much more difficult to learn to use libanki.
Perhaps appropriate to ask here: when I add new cards to a deck and use my program to list the content of a deck, it used to show those new cards immediately (had to sync, I believe). Now, however, it seems that syncing isn’t enough and that I must switch profile or close Anki for the new cards to appear in the DB. Is there something I can do to flush the new cards into the DB?
The only docs at the moment are at https://addon-docs.ankiweb.net/#/
Any outstanding changes are flushed at the start of the sync. Copying the db file while it’s open is not a use case sqlite tries to support however, so the behaviour there may be undefined.
Is that this? libanki · PyPI