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

any chance of your script supporting the new MMDB format? #10

Open
jhaar opened this issue Apr 15, 2016 · 1 comment
Open

any chance of your script supporting the new MMDB format? #10

jhaar opened this issue Apr 15, 2016 · 1 comment

Comments

@jhaar
Copy link

jhaar commented Apr 15, 2016

Hi there

I'd first like to thank you for your csv2dat.py script. I have used it to merge the lat/long positions of our internal 10/8 network subnets into the maxmind CSV files and now we can do things like have maps showing our internal devices using websites/etc as well as Internet :-)

However, now we're seeing applications that only support the newer MMDB format. Have you thought about adding support for that as an option? So far there only seems to be a perl "writer" from Maxmind - but nothing for python :-(

In any case, thanks for your work!

Jason

@mnicky
Copy link

mnicky commented Nov 27, 2017

Hi Jason, I was successful using pyperler to call Maxmind's writer perl library from python. Example code:

#!/usr/bin/env python3

import pyperler

i = pyperler.Interpreter()
tree = i.use("MaxMind::DB::Writer::Tree")
types_t = i("my %types = (city => 'map', \
                          traits => 'map', \
                          country => 'map', \
                          ); sub { $types{ $_[0] } }")

treeInst = tree.new(ip_version=6,
                    record_size=28,
                    database_type='GeoIP2-City',
                    languages=['en'],
                    description = {'en': 'test-db'},
                    map_key_type_callback=types_t,
                    alias_ipv6_to_ipv4=True
                    # merge_record_collisions = True
                    )

treeInst.insert_network(ip, record)
# ...

fh = i.use("FileHandle")
fh = fh.new()
fh.open('>' + 'geocity.mmdb')
treeInst.write_tree(fh)

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