QQWry.ipdb is a Delphi/Pascal reader for IPIP.net .ipdb geolocation databases. It is designed for Delphi and Free Pascal applications that need simple offline IP lookup support and currently focuses on IPDB databases such as QQWry-Raw.ipdb and QQWry.ipdb.
- Reads IPIP.net
.ipdbdatabase files from a file path orTStream. - Supports IPv4 and IPv6 lookups when the database contains both trees.
- Exposes metadata such as build time, field list, language offsets, node count, total size, and IP version support.
- Provides raw field lookup with
TIPDBFile.Find. - Provides typed lookup records with
TIPDBCity.FindInfo,TIPDBDistrict.FindInfo,TIPDBBaseStation.FindInfo, andTIPDBIDC.FindInfo. - Provides IPv4 record enumeration with
TIPDBDataBase.Seek,RecordCount, andLanguage. - Handles both IPDB Raw and Std layouts:
- Raw layout: 5 compatible fields, normalized by the reader when
district_nameis absent. - Std layout: 8 structured fields, returned without extra normalization.
- Raw layout: 5 compatible fields, normalized by the reader when
- Derives country and continent codes for Raw QQWry data through a built-in country-name lookup table.
- Includes DUnit tests and demos for VCL, FMX, Delphi console, and Free Pascal.
- Delphi 2009 or later, or Free Pascal with
{$MODE DELPHI} - A valid
.ipdbdatabase file such asQQWry.ipdb JsonDataObjects.pasfrom theSourcedirectory (already included in this repository)
- Clone this repository.
- Add the
Sourcedirectory to your Delphi or Lazarus project search path. - Add
IPDBto your unitusesclause. - Place an
.ipdbdatabase file where your application can read it.
uses
System.SysUtils, IPDB;This repository includes Delphinus metadata:
Delphinus.Info.jsonDelphinus.Install.json
After publishing the repository, it can be indexed by Delphinus as a source-only package.
Please download the latest qqwry.ipdb from the nmgliangwei/qqwry.ipdb project and place it where your application can access it.
Direct download:
https://raw.githubusercontent.com/nmgliangwei/qqwry.ipdb/main/qqwry.ipdbhttps://raw.githubusercontent.com/nmgliangwei/qqwry.ipdb/main/qqwry-raw.ipdb
The database files are data products from their respective providers. Check the provider license and redistribution terms before publishing them with a release or committing them to a public repository.
Raw QQWry IPDB files expose five compatible fields:
country_name
region_name
city_name
owner_domain
isp_domain
For this layout, FindInfo normalizes the combined location and ISP text into standard city fields and derives country_code and continent_code.
Standard QQWry IPDB files expose eight structured fields:
country_name
region_name
city_name
district_name
owner_domain
isp_domain
country_code
continent_code
For this layout, FindInfo preserves the structured fields from the database.
uses
System.SysUtils, IPDB;
procedure LookupIP;
var
DB: TIPDBCity;
Info: TIPDBCityInfo;
begin
DB := TIPDBCity.Create('QQWry.ipdb');
try
Info := DB.FindInfo('8.8.8.8');
Writeln(Info.CountryName);
Writeln(Info.RegionName);
Writeln(Info.CityName);
Writeln(Info.ISPDomain);
Writeln(Info.CountryCode);
Writeln(Info.ContinentCode);
finally
DB.Free;
end;
end;var
DB: TIPDBCity;
Values: TArray<string>;
begin
DB := TIPDBCity.Create('QQWry.ipdb');
try
Values := DB.Find('8.8.8.8', 'CN');
Writeln(Values[0]);
finally
DB.Free;
end;
end;var
DB: TIPDBCity;
Stream: TFileStream;
begin
Stream := TFileStream.Create('QQWry.ipdb', fmOpenRead or fmShareDenyWrite);
try
DB := TIPDBCity.Create(Stream);
try
Writeln(DB.FindInfo('8.8.8.8').ToString);
finally
DB.Free;
end;
finally
Stream.Free;
end;
end;TIPDBDataBase builds an in-memory IPv4 record index and lets you iterate records by index:
var
DB: TIPDBDataBase;
StartIP, EndIP: string;
Values: TArray<string>;
I: Integer;
begin
DB := TIPDBDataBase.Create('QQWry.ipdb');
try
DB.Language := 'CN';
for I := 0 to DB.RecordCount - 1 do
begin
if DB.Seek(I, StartIP, EndIP, Values) then
Writeln(Format('%s - %s: %s', [StartIP, EndIP, Values[0]]));
end;
finally
DB.Free;
end;
end;Writeln(DB.BuildDateTime);
Writeln(FormatDateTime('yyyy-mm-dd hh:nn:ss', DB.Meta.BuildDateTime));
Writeln(DB.Meta.Fields.CommaText);
Writeln(DB.Meta.NodeCount);
Writeln(DB.Meta.TotalSize);
Writeln(BoolToStr(DB.IPv4Support, True));
Writeln(BoolToStr(DB.IPv6Support, True));The reader raises EIPDB for invalid database files, unsupported IP versions, unsupported languages, invalid IP input, and missing data. Wrap database loading and lookups in normal Delphi try/except blocks when integrating into an application.
- Source files are kept as UTF-8 with Windows CRLF line endings.
Findreturns database fields exactly as stored for the selected language.FindInfomaps lookup results into typed records. For Raw QQWry data, the reader splits combined location and ISP text and may add derived country and continent codes.TIPDBCityInfoalso supports IPIP-style extended fields such as ASN, timezone, coordinates, district info, and IDC/base-station markers when the database provides them.FindJsonis private onTIPDBFile; application code should useFindorFindInfo.TIPDBDataBase.Seekcurrently enumerates IPv4 records only.
Contributions are welcome! Please fork this repository and submit pull requests with your improvements. Behavior changes should include matching DUnit coverage in UnitTest/.
This project is licensed under the Mozilla Public License 2.0. See LICENSE for details.
Thanks to the QQWry / CZ88 ecosystem for providing the IPDB database format used by this project.
If you need a more accurate or commercially supported dataset, consider the official commercial offerings from the QQWry provider.