Study now comes up with problem, check database deletes cards

Hi, I would be grateful for any help.

Before we begin, I would like to say I have searched Anki Forums, followed the trouble shooting steps with no luck. I have manually downloaded a back up and imported to a new user, still the same issue. I have tried to restart the laptop, also no luck.
In addition, I only use Anki on this one device via the Anki App (I very rarely use anki web and the couple of occasions I have, I ensure a one way sync occurs) and have never had any syncing issues.
In addition, I create all of my own cards and have never imported a deck from anyhwhere.

Within the last couple of days, I have updated to the latest version of anki (using on MacBook only) after being prompted several times. Version ⁨24.11 (87ccd24e)⁊
Python 3.9.18 Qt 6.6.2 PyQt 6.6.1. I have copied and pasted the debug info below:

Anki 24.11 (87ccd24e) (ao)
Python 3.9.18 Qt 6.6.2 PyQt 6.6.1
Platform: macOS-13.5.2-x86_64-i386-64bit

===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
Image Occlusion Enhanced [‘1374772155’, 2022-04-09T08:15, ‘None’, ‘’]

===IDs of active AnkiWeb add-ons===
1374772155

===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])

When I go to study one of my decks, it comes up with a notification stating, “Anki encountered a problem. Please follow the troubleshooting steps. The problem may be caused by an add-on” and I am unable to study certain decks due to this. I logged onto Anki Web to see if it is an app issue and the same message appears.
When I browse a deck, I notice some cards are greyed out (unable to see what the content is or the type of card) and they state, “your database appears to be in an inconsistent state. Please use the check database action. No such card template: X” (X denoting a number). These are the decks I am unable to study at all. I am still able to study other decks not containing any of these greyed-messaged cards.
For further information, the only add-ons I ever downloaded from the anki website is the image occlusion add-on. This had to be updated a couple of years ago when a new version of anki was downloaded.
The cloze deletion type of cards I have created have always been created without the need to download an add on from the anki website; previously, it has always been one of the options within the anki app drop down menu when selecting the type of card created.
I have browsed through all of my cards to try and gauge where the issue may be; from what I can tell, it appears to be affecting all cards where “cloze deletion” has been previously used when creating the cards. I would like to stress that prior to this, I have not had any issues with these types of cards.

I have tried using the check database functions. Although this allows me to study my decks, it states that 100 cards have been deleted. Unfortunately, I am unable to see which cards have been deleted and they are from multiple decks. This is evidently causing some stress as I am approaching med school finals and would be grateful for your help.

Even if there was a way to see which cards are deleted or bring them back, even to a new user on anki, though not ideal, I would be happy with that so I am not losing content as it’s difficult to tell which cards are being deleted through the check database function.

Trouble shooting pages I have already viewed and followed steps for prior to posting this include:

/your-database-appears-to-be-in-an-inconsistent-state-please-use-the-check-database-action-no-such-deck-1723223508553/48550 and /help-deleted-cards/23700 (it does not allow me to post this with the full link contained)

Many Thanks

Just to make sure: have you tried disabling the add-on and restarting Anki; does the issue persist?

And/or starting in Safe Mode?

1 Like

Hi,

Yes, apologies I forgot to mention I have tried to restart anki in safe mode to disable the add-on but the issue unfortunately does not resolve.

Thank you for pointing this out

Edit: Nevermind the previous post. Image occlusion and cloze share some code but you probably meant the actual text clozes.

Could you check if downgrading to your previous version makes those decks working again?

Hi, I have tried downgrading to the previous version after your advice and unfortunately I get the same error message. I also tried opening the downgraded version in safe mode but no luck with this.

Thank you for your suggestion, it helps narrow down the issue

So you used the default cloze cards in anki and now those cloze cards don’t work anymore and you get database related issues?

Do you have a cloze card type if you go to tools > manage card types?
And did you ever change the cloze back / front templates?

[quote=“Anon_0000, post:6, topic:53247”]
So you used the default cloze cards in anki and now those cloze cards don’t work anymore and you get database related issues? [/quote]
Yes, this is correct

Yes, there is a cloze card type when I go to tools > manage card types.
I have never changed the cloze back/ front templates, I have also checked this again after your advice, thank you.

I’m not sure how helpful this is, I have copied and pasted the debug info below when the error message appears when I try to study the affected decks:

Anki 24.11 (87ccd24e) (ao)
Python 3.9.18 Qt 6.6.2 PyQt 6.6.1
Platform: macOS-13.5.2-x86_64-i386-64bit

Traceback (most recent call last):
File “aqt.webview”, line 53, in cmd
File “aqt.webview”, line 169, in _onCmd
File “aqt.webview”, line 725, in _onBridgeCmd
File “aqt.overview”, line 98, in _linkHandler
File “aqt.main”, line 770, in moveToState
File “aqt.main”, line 791, in _reviewState
File “aqt.reviewer”, line 183, in show
File “aqt.reviewer”, line 203, in refresh_if_needed
File “aqt.reviewer”, line 261, in nextCard
File “aqt.reviewer”, line 376, in _showQuestion
File “anki.cards”, line 140, in question
File “anki.cards”, line 156, in render_output
File “anki.template”, line 222, in render
File “anki.template”, line 269, in _partially_render
File “anki._backend_generated”, line 1480, in render_existing_card
File “anki._backend”, line 172, in _run_command
anki.errors.InvalidInput: missing template

===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
Image Occlusion Enhanced [‘1374772155’, 2022-04-09T08:15, ‘None’, ‘’]

===IDs of active AnkiWeb add-ons===
1374772155

===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])

Well, that’s odd.
I mean you could go to your anki data folder and look into the sqlite3 database file (collection.anki2).

There is a table called notes which shows your notes, e.g.:

The mid column shows the id of your notetype, found in the notetype table. In this case, the id is 1734378916698 which corresponds to LĂźckentext (german word for cloze deletion).

The fields for that notetype are stored in table fields:

The blue marked rows correspond to the cloze card (see the id in the first column), second column shows the order in which those fields are ordered (starting from 0), third column shows the name of that field.
The templates table should have a matching entry, like mine does:

Considering you got

maybe here lies your problem.

In any case, in theory all your cards are still in the database so you could retrieve all info about them. If your database isn’t seriously damaged, that is. Maybe you can check that your entries for the cloze cards looks valid? Keep in mind that your notetype id will probably be different.

I tested it just now. I deleted this blue row from the templates table and now get the same error as you do @SNH18:

Error output
Anki 24.11 (87ccd24e)  (ao)
Python 3.9.18 Qt 6.6.2 PyQt 6.6.1
Platform: Linux-6.1.0-0.deb11.21-amd64-x86_64-with-glibc2.31

Traceback (most recent call last):
  File "aqt.webview", line 53, in cmd
  File "aqt.webview", line 169, in _onCmd
  File "aqt.webview", line 725, in _onBridgeCmd
  File "aqt.overview", line 98, in _linkHandler
  File "aqt.main", line 770, in moveToState
  File "aqt.main", line 791, in _reviewState
  File "aqt.reviewer", line 183, in show
  File "aqt.reviewer", line 203, in refresh_if_needed
  File "aqt.reviewer", line 261, in nextCard
  File "aqt.reviewer", line 376, in _showQuestion
  File "anki.cards", line 140, in question
  File "anki.cards", line 156, in render_output
  File "anki.template", line 222, in render
  File "anki.template", line 269, in _partially_render
  File "anki._backend_generated", line 1480, in render_existing_card
  File "anki._backend", line 172, in _run_command
anki.errors.InvalidInput: missing template

===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
AnkiWebView Inspector ['31746032', 2023-06-27T21:26, 'None', '']
Image Occlusion Enhanced ['1374772155', 2022-04-09T09:15, 'None', '']
Review Heatmap ['1771074083', 2022-06-30T03:43, 'None', '']
Study Time Stats ['1247171202', 2024-02-24T17:59, 'None', '']

===IDs of active AnkiWeb add-ons===
1247171202 1374772155 1771074083 31746032

===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
Advanced Browser ['874215009', 2023-10-21T16:34, 'None', '']
Syntax Highlighting NG ['566351439', 2024-07-19T11:46, 'None', '']

Adding that row back in solved it:

INSERT INTO "main"."templates" ("ntid", "ord", "name", "mtime_secs", "usn", "config") VALUES ('1734378916698', '0', 'LĂźckentext', '0', '0', X'0a0e7b7b636c6f7a653a546578747d7d12277b7b636c6f7a653a546578747d7d3c62723e0a7b7b52c3bc636b73656974652045787472617d7d4082dab3d8d0b6e1fcb601');

You will need the proper id and name of your cloze card. The blob (config column) is important too. This is language dependend though and also depends on whether you had changed anything in the template before. The part with

X'0a0e7b7b636c6f7a653a546578747d7d12277b7b636c6f7a653a546578747d7d3c62723e0a7b7b52c3bc636b73656974652045787472617d7d4082dab3d8d0b6e1fcb601'

shows the hex value of the cloze template.
I know the correct value for my language (german) because I got the hex like this from a working profile:

SELECT hex(config) FROM main.templates;

Here’s an example of a plain text version of that blob (data):

Of course, your issue could be a different one. But maybe this helps.

1 Like

I’ll just interject a few general cautions here –

  • Don’t edit or manipulate your database directly unless you know what you’re doing
  • Don’t edit your database while Anki is running
  • Make a backup before you try anything [File > Create Backup]
  • Make a copy of your database to make your changes so that you still have your original

//end public service announcement

1 Like

True, should have mentioned those. Thanks :+1:

1 Like

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