I previously wrote about accessing the Anki database using Python on mac OS. Extending that post, I’ll show how to work with a specific deck in this short post.
To use a named deck you’ll need its deck ID. Fortunately there’s a built-in method for finding a deck ID by name:
col = Collection(COLLECTION_PATH)
Now in queries against the
notes tables we can apply the deck ID to restrict them to a certain deck. For example, to find all of the cards currently in the learning stage:
query = """SELECT COUNT(id) FROM cards where type = 1 AND did = dID"""
And close the collection: