Skip to content

Commit 1f6df9a

Browse files
committed
Add separate database usage instructions
It is clearer if we don't try to explain both together.
1 parent 91440cd commit 1f6df9a

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

README.rst

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ IP geolocation is inherently imprecise. Locations are often near the center of
4242
the population. Any location provided by a GeoIP2 database or web service
4343
should not be used to identify a particular address or household.
4444

45-
Usage
46-
-----
45+
Web Service Usage
46+
-----------------
4747

4848
To use this API, you first create either a web service object with your
4949
MaxMind ``account_id`` and ``license_key`` or a database reader object with the
@@ -169,8 +169,22 @@ returns any status code besides 200, 4xx, or 5xx, this also becomes an
169169
Finally, if the web service returns a 200 but the body is invalid, the client
170170
throws a ``GeoIP2Error``.
171171

172+
Database Usage
173+
--------------
174+
175+
To use the database API, you first construct a ``geoip2.database.Reader`` using
176+
the path to the file as the first argument. After doing this, you may call the
177+
method corresponding to request type (e.g., ``city`` or ``country``), passing it
178+
the IP address you want to look up.
179+
180+
If the request succeeds, the method call will return a model class for the
181+
end point you called. This model in turn contains multiple record classes,
182+
each of which represents part of the data for the record.
183+
184+
If the request fails, the reader class throws an exception.
185+
172186
Database Example
173-
-------------------
187+
----------------
174188

175189
City Database
176190
^^^^^^^^^^^^^

0 commit comments

Comments
 (0)