-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support opening apkg files out of the box #93
Comments
Hi @Blocked. Thanks for opening the issue 😊. I don't really have an answer for your ight away, but this error seems to be relatively unrelated to most of the code from import sqlite3
import pandas as pd
connection = sqlite3.connect("/data/data/com.termux/files/home/.venv/test.apkg")
pd.read_sql_query("SELECT * FROM cards", connection) |
Perhaps as an even simpler test to see if this is also unrelated to import sqlite3
con = sqlite3.connect("/data/data/com.termux/files/home/.venv/test.apkg")
cursor = con.cursor()
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
print(cursor.fetchall())
cursor.close()
con.close() this should print all tables in the file. |
You could also directly try to use the command line interface of |
@klieret Thanks 👍 Only
Any direction? |
Hmm, very interesting. Where is the anki database from? Is it from AnkiDroid? Then it looks like AnkiDroid is using a different format for its database than Anki desktop. I've honestly never considered that someone might want to use this with AnkiDroid, so I've never tested this. I'm also curious about your use case ;) |
@allcontributors please add @Blocked for bug |
I don't think there's any db structure difference. The apkg files are from https://ankiweb.net. eg: https://ankiweb.net/shared/info/965641886 Also, I can't find any difference in database structures in ankidroid here: https://github.com/ankidroid/Anki-Android/wiki/Database-Structure My intention is to simply to manipulate cards on droid itself. |
I've put up a pull request to add @Blocked! 🎉 |
Okay, I see this too now (using this tiny deck). So your use case then is to manipulate the cards before (!) you import them to your profile? |
OK, but it seems like this is actually just a zip file. So if you unzip the file, you will get pictures, as well as a human readable file |
I've actually just tested with the deck and it works all fine :) c = Collection("collection.anki2")
c.notes
c.cards
c.revs |
I don't think there's a difference between shared deck and exported deck. I checked a exported deck just now and I get the same |
Interesting. So usually |
@klieret Thank you!! It works after extracting |
If you think it'll be useful, consider adding direct support for shared deck Thanks again👍 |
I will definitely add example code in the next few days. I am still not sure if I can add the read and especially write function to |
Love this thread as I was experiencing the same issue! Was this ever added to the docs? e.g. I can't find it here https://ankipandas.readthedocs.io/en/latest/troubleshooting.html Would be super useful to include native "exported deck" support |
Thanks for the ping. Yes, indeed this wasn't added yet. I hope I can find some time this week! |
Thanks so much @klieret ! Hmm this isn't working for me, my Anki deck (attached here:https://www.dropbox.com/s/l4hqbuckxn86le7/anki-raw-3-23-23.apkg?dl=0) only worked when I extracted it first... Code:
Output: |
The collection from the extracted deck has cards, but the collection from the raw deck only has one broken card. I hope that's helpful! |
Thanks for the feedback, I hope I get to test the code against the example you submitted next week |
Hi @rpryzant. Sorry for the late reply. I looked at your file and for me it simply seems to be corrupted. Because I see the following output:
I do not see any issue when I use apkgs that I find on the internet. |
what you expected: See Cards
what happened instead: Thrown a error on
a.cards
Last log messages of
AnkiPandas
sqlite3.sqlite_version
returns3.36.0
in iPythonThe text was updated successfully, but these errors were encountered: