Advertisement
felmoltor

Convert Maxmind CSV GeoIP to SQLite

Jan 12th, 2015
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.35 KB | None | 0 0
  1. ####################################################################################################################
  2. # Convert CSV GeoIPCountryWhois.csv file of Maxmind to a sqlite database to use with Kippo and other bash scripts: #
  3. ####################################################################################################################
  4.  
  5. pepe@juan:~/maxmind$ sqlite3 GeoIPCountryWhois.db
  6. SQLite version 3.5.13 2011-06-11 02:05:22
  7. Enter ".help" for instructions
  8. Enter SQL statements terminated with a ";"
  9. sqlite> .tables
  10. sqlite> .mode csv
  11. sqlite> .separator '","'
  12. sqlite> create table  GeoIPCountryWhois(initip varchar(15),endip varchar(15),initipdec integer,endipdec,cty_acronym varchar(3),cty_name varchar(20));
  13. sqlite> .import GeoIPCountryWhois.csv GeoIPCountryWhois
  14. sqlite> .tables
  15. GeoIPCountryWhois
  16. sqlite> select * from GeoIPCountryWhois limit 10;
  17. 1.0.0.0,1.0.0.255,16777216,16777471,AU,Australia
  18. 1.0.1.0,1.0.3.255,16777472,16778239,CN,China
  19. 1.0.4.0,1.0.7.255,16778240,16779263,AU,Australia
  20. 1.0.8.0,1.0.15.255,16779264,16781311,CN,China
  21. 1.0.16.0,1.0.31.255,16781312,16785407,JP,Japan
  22. 1.0.32.0,1.0.63.255,16785408,16793599,CN,China
  23. 1.0.64.0,1.0.127.255,16793600,16809983,JP,Japan
  24. 1.0.128.0,1.0.255.255,16809984,16842751,TH,Thailand
  25. 1.1.0.0,1.1.0.255,16842752,16843007,CN,China
  26. 1.1.1.0,1.1.1.255,16843008,16843263,AU,Australia
  27. sqlite>.q
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement