Looking for help getting review stats (eg is:new or not) in an addon based on card id (or something else)

Not sure if this sort of question is ok, but it’s one of those things that will probably take someone who knows about 5s, whereas if I try to dig up the answer, it’ll take a long time.

In an add-on I’m developing, I have the following query:

for row in mw.col.db.execute("""
    select c.nid, n.id from cards c, notes n
    where c.nid = n.id and mid = ?""", m['id']):
  cid = row[0]
  nid = row[1]

The thing I’m not sure how to get is the learning status of the card. Getting a handle on the note is easy enough: mw.col.getNote(nid) but I’m not sure how to get information about the card, in particular, whether it is new or not. Essentially, want True if the card “is:new”, false otherwise. I imagine it might be in the database above, so it might be easier to return it with the query…but I have no idea where to get the schemas for these databases (would love pointers on that, and I sort of ask another question related to this issue below)

Any pointers? Would be much appreciated.

Somewhat tangential, but…I was wondering if you might consider a stickied thread for minor questions like this? I guess I don’t know how much traffic it would get, but I think it’d be nice to have a place to ask this sort of thing (assuming such questions are welcome).

Second, but is there a better way of going about figuring this stuff out? I’ve never gotten a great development flow going for add-ons, I end up just trying to find out an add-on that does what I want and then copying it because I haven’t yet found out a great way to figure out the model. I’ve read the code where I have to, but for stuff like database schemas and whatnot, not sure what the recommended way is to sort of get a grip on all that (not knowing how to approach this is why I am asking this question at all!)

There’s this

1 Like

oh nice! a little odd that something so useful is buried in ankidroid docs, but great resource. thank you!

though I wonder how this is referred to from python, given that type is a reserved keyword. although for my uses I could probably just get the boolean answer I want in the sql query…

But type isn’t a reserved keyword? Both of these will give you 1, or learning:

aqt.mw.col.get_card(1652658634540).type
aqt.mw.col.db.scalar("select type from cards where id = 1652658634540")
1 Like