Skip to main content

A Python package for working with world cities, countries, regions database

Project description

AigeoDB

A Python package for working with world cities, countries, regions database. This package provides easy access to a comprehensive database of world locations including cities, countries, regions, subregions, and states.

Features

  • Easy-to-use interface for querying geographical data
  • Built-in database downloader and updater
  • Support for searching cities, countries, and regions
  • Geolocation features (nearby cities search)
  • SQLAlchemy models for all database entities

Installation

pip install aigeodb

Quick Start

from aigeodb import DatabaseManager

# Initialize the database manager
db = DatabaseManager()

# Search for cities
cities = db.search_cities("Moscow", limit=5)
for city in cities:
    print(f"{city.name}, {city.country_code}")

# Get country information
country_info = db.get_country_info("US")
print(country_info)

# Find nearby cities
nearby = db.get_nearby_cities(40.7128, -74.0060, radius_km=100)
for city in nearby:
    print(f"{city.name}, {city.state_code}")

Database Structure

The package includes the following data:

  • Countries (250 records)
  • Regions (6 records)
  • Subregions (22 records)
  • States/Regions/Municipalities (5,038 records)
  • Cities/Towns/Districts (151,072 records)

Updating Database

To update the database to the latest version:

from aigeodb import DatabaseDownloader

downloader = DatabaseDownloader()
downloader.update_databases()

API Reference

DatabaseManager

Main class for interacting with the database:

# Initialize
db = DatabaseManager()

# Available methods
db.search_cities(term, limit=10)
db.get_country_info(country_code)
db.get_nearby_cities(latitude, longitude, radius_km=100)
db.get_cities_by_country(country_code)
db.get_states_by_country(country_code)
db.get_statistics()

License

This project is licensed under the MIT License - see the LICENSE file for details.

Credits

This package uses data from countries-states-cities-database repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aigeodb-0.1.0.tar.gz (13.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aigeodb-0.1.0-py2.py3-none-any.whl (13.7 MB view details)

Uploaded Python 2Python 3

File details

Details for the file aigeodb-0.1.0.tar.gz.

File metadata

  • Download URL: aigeodb-0.1.0.tar.gz
  • Upload date:
  • Size: 13.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for aigeodb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ef00cd0f110a24c3eb0404127a7708fff5a984b18d8df6701705be8cc8f9fe48
MD5 d52735df2463d15583fc738e574ddbd4
BLAKE2b-256 337b2504dcc21c1e06b0e5f3d3f326bafddaa33b9498278b56afda8fd10f2d2c

See more details on using hashes here.

File details

Details for the file aigeodb-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: aigeodb-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.7 MB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for aigeodb-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f5195d79f588d0e22fdd4163c22b3c14990c7676d0094d3b62f966f1d1b12ff1
MD5 3b7d54c0771bd00242387c8ae1390479
BLAKE2b-256 6361961822ef9710a541b13a6e08330d292f956ddfceb2a0bb984ef093989ba2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page