ZORAN.DB.IP.Importer is a tool that imports into Microsoft SQL Server the freely available geolocation database offered by www.db-ip.com.
For more information please check the documentation https://github.com/zoranmax/ZORAN.DB.IP.Importer/wiki or here http://www.agile-code.com/blog/import-db-ip-com-database-data-to-microsoft-sql-server-with-zoran-db-ip-importer-tool/
Download the compiled application
- Download the free database from this location http://www.db-ip.com/db/download/city. The database comes in the CSV format.
- Change the Connection String in the ZORAN.DB-IP-Importer.exe.config file to point to the Microsoft SQL Server database. This is done by changing the value of the connection string named “DB_IP”
- Once again, in the file ZORAN.DB-IP-Importer.exe.config, enter the path to the CSV file by changing the value of the AppSettings value “db-ip-file-path”
- Run the two provided scripts dbip_city.sql and dbip_city_stage.sql against your database. This will create two tables (staging and the “live” table). Obviously this should be done only once , the first time you use this application.
- Run the application.
In order to avoid any complex management of the inserts and updates of the already existing data, I’ve chosen the approach of the staging table and the “live” table.
The importing process operations are as follows:
- Read the CSV file (for the time being the file is fully loaded in memory. With the latest CSV files this might be an issue for some as the file has grown significantly).
- Truncate the data from the “Staging” table
- Load the data from the CSV file to the “Staging” table
- In a transaction, move all the data from the “staging” table to the “live” table.