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

Getting around file size limits? #17

Closed
blixt opened this issue Nov 5, 2015 · 3 comments
Closed

Getting around file size limits? #17

blixt opened this issue Nov 5, 2015 · 3 comments

Comments

@blixt
Copy link

blixt commented Nov 5, 2015

Is there a way to get around file size limits (e.g., Google App Engine has a limit of 32 MB, which the GeoLite2 city database exceeds)?

The best solution I can think of is to allow a buffer to be passed in instead of the filename, so that the file can be loaded either as a .zip file and extracted in memory, or segmented into multiple files and reassembled in memory.

@blixt
Copy link
Author

blixt commented Nov 5, 2015

For people who want a quick fix, you can monkey patch the reader object:

# Monkey-patch the MaxMind database reader to read from compressed files.
# Note: mmap won't work with compressed files.
def open_compressed(name, mode='r'):
    # TODO: Could support tarfile, zipfile etc. here.
    if name.endswith('.gz'):
        import gzip
        return gzip.GzipFile(name, mode)
    return open(name, mode)
maxminddb.reader.open = open_compressed

I recommend using MODE_MEMORY because mmap won't work with this solution and traversing a compressed file (MODE_FILE) is not going to perform as well.

@oschwald
Copy link
Member

oschwald commented Nov 6, 2015

Thanks for providing the workaround. I'll leave this open as we may consider opening from a buffer in the future if there is demand. I think this is the first such request we have received.

@oschwald
Copy link
Member

#33 provided a way to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants