Comments (5)
For reference : I'm using some more naive code :
from ankipandas import Collection, find_db
from shutil import copy
from pathlib import Path
original_db = find_db(user=profile_name) # profile name supplied by user, None to use the first found
Path.mkdir(Path("cache"), exist_ok=True) # create cache folder
temp_db = copy(original_db, f"cache/{deckname.replace(' ', '_')}") # copying database to cache
col = Collection(path=temp_db) # load ankipandas on the temporary directory
I'll use this in the future but I think it's still a very valuable feature to implement (for example with an argument like read_only=True
)
Thanks a lot for being so reactive and helpful last time, it was very useful and I'm really appreciative of it.
Have a nice day!
from ankipandas.
Hi @thiswillbeyourgithub AnnA looks really cool!
How about a quick & dirty approach: You can probably simply copy the database file to a temporary directory and open that. This will basically give you read only access.
So something like this (not tested at all, from top of my head):
from pathlib import Path
import shutil
import tmpfile
import ankipandas as ap
db_path = ap.paths.find_db()
with tempfile.TemporaryDirectory() as tmpdirname:
new_loc = Path(tempdirname) / db_path.name
shutil.copy(db_path, new_loc)
col = ap.Collection(new_loc)
# do your stuff with the collection
# Copy will get deleted
from ankipandas.
Thanks a bunch, I thought about doing this but was not sure about how to create temporary file on all platforms.
Thanks a lot!
from ankipandas.
Sure, let me know if it works!
from ankipandas.
I'll try to, but I won't try it for quite some time. Don't wait for me :)
from ankipandas.
Related Issues (20)
- How to get the history of reviews of a card/deck? HOT 3
- Document different tables and their content
- How to get the creation date of a card? HOT 2
- Accessing deck settings HOT 9
- Update doesn't work ? What is the correct way of updating single notes ? HOT 11
- Future warning about `Index.__and__`
- Harden interface by marking arguments as keyword-only
- Missing database indices HOT 5
- Columns in documentation HOT 3
- Thank you and similarity scanner I made with it. HOT 4
- Writing to collection breaks synchronization and editing in Ankidroid HOT 13
- is it possible to read an anki portable base? HOT 1
- Incompatibilities with pandas 2.0 HOT 1
- sub- and superdeck support HOT 6
- Problems when adding a note HOT 2
- "Ankipandas Conversion Issue: Erroneous Update Messages in Anki Database Export"
- Plug: I made a tool that uses ankipandas (it's AI powered search through anki and any other filetype) HOT 1
- Support opening apkg files out of the box HOT 23
- Reading all notes from a deck HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ankipandas.