Skip to content
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

Suggestion: build and distribute as a SQLite DB file #3

Closed
simonw opened this issue Nov 9, 2020 · 3 comments
Closed

Suggestion: build and distribute as a SQLite DB file #3

simonw opened this issue Nov 9, 2020 · 3 comments

Comments

@simonw
Copy link

simonw commented Nov 9, 2020

This library currently distributes data as a built JSON file, which has to be read into memory in full.

If the library used a binary SQLite DB file it could run lookups against an index and avoid needing to load the entire file into memory.

Since Python includes sqlite3 in the Python standard library this could be done without needing any extra library dependencies.

@polm
Copy link
Owner

polm commented Nov 9, 2020

That's a great idea - thanks for the suggestion.

I've never packaged a library like that before; what's the right way to handle connections? Should I open a connection at import time and re-use it or make a connection for every query?

@polm
Copy link
Owner

polm commented Nov 21, 2020

So I realized one issue with this - because JSON can be decompressed at runtime, it only takes up roughly 3MB on disk. In contrast vanilla sqlite can't be compressed on disk, so it's 70MB. That's not a big deal for most applications (and it's compressed for download anyway) but it's something to keep in mind.

I have working code doing this in the feature-sqlite branch.

@polm
Copy link
Owner

polm commented Dec 1, 2020

Just released this as v0.2.0.

@polm polm closed this as completed Dec 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants