GeoAlchemy2
Using SQLAlchemy with Spatial Databases
Decision gist · record as of 2026-08-14
Yes. GeoAlchemy2 is actively maintained, has low install friction, carries a permissive MIT license, and fills a clear need for ORM-based spatial database access. It is well-established and supports current Python versions. Install it if you need to work with geographic data in a SQLAlchemy-based application.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires a spatial database backend (such as PostGIS) to be installed and configured separately; Python 3.10 or later.
- Low friction installation with only two runtime dependencies (SQLAlchemy and packaging).
- Active maintenance with recent releases and a stable repository.
License · maintenance · safety
MIT (permissive) — MIT license permits commercial and private use with minimal restrictions.
last release 2026-05-12 (94 days) · last repo commit 2026-07-22 · 709 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 5,163,891 downloads/mo, #2,152 on PyPI
Alternatives
Verify before relying
pip install geoalchemy2
from geoalchemy2 import Geometry
from sqlalchemy import Column, Integer, create_engine
from sqlalchemy.orm import declarative_base
Base = declarative_base()
class Location(Base):
__tablename__ = 'locations'
id = Column(Integer, primary_key=True)
geom = Column(Geometry('POINT'))- Which spatial database backends are supported (PostGIS, SpatiaLite, etc.)
- Whether a spatial database system must be installed separately
- Performance characteristics for large geographic datasets
What it is and what it does
GeoAlchemy2 is a Python toolkit that bridges SQLAlchemy and spatial databases, allowing you to work with geographic data types and spatial queries through an ORM interface. It builds on SQLAlchemy's declarative system to map geographic columns and operations to database-native spatial types, letting you query and manipulate geographic data using Python objects rather than raw SQL.
The package is designed for applications that need to store, retrieve, and analyze geographic information—such as location-based services, mapping applications, or GIS analysis workflows. It handles the translation between Python spatial objects and the spatial data types supported by your underlying database, abstracting away database-specific SQL syntax for common geographic operations.
Use it for
- Build location-based web services that query geographic points, polygons, or routes stored in a spatial database
- Develop GIS analysis tools that need to perform spatial operations like distance calculations or intersection tests through an ORM
- Create mapping applications that store and retrieve geographic features alongside relational data
- Implement geofencing or proximity-based filtering in applications backed by a spatial database
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
GeoAlchemy2 is actively maintained, has low install friction, carries a permissive MIT license, and fills a clear need for ORM-based spatial database access. It is well-established and supports current Python versions. Install it if you need to work with geographic data in a SQLAlchemy-based application.
Install
geoalchemy2 on PyPI
Before you install
Low friction installation with only two runtime dependencies (SQLAlchemy and packaging). Active maintenance with recent releases and a stable repository.
Requires a spatial database backend (such as PostGIS) to be installed and configured separately; Python 3.10 or later.
License in practice
MIT license permits commercial and private use with minimal restrictions.
Quickstart
pip install geoalchemy2
from geoalchemy2 import Geometry
from sqlalchemy import Column, Integer, create_engine
from sqlalchemy.orm import declarative_base
Base = declarative_base()
class Location(Base):
__tablename__ = 'locations'
id = Column(Integer, primary_key=True)
geom = Column(Geometry('POINT'))
Verify before relying
- Which spatial database backends are supported (PostGIS, SpatiaLite, etc.)
- Whether a spatial database system must be installed separately
- Performance characteristics for large geographic datasets
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagesSQLAlchemypackaging |
| Maintenance | Actively maintained 94 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 5,163,891 / month, #2,152 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaEnvironment :: PluginsIntended Audience :: Information TechnologyOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Topic :: Scientific/Engineering :: GIS |
Evidence: geoalchemy2-0.20.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “sqlalchemy spatial database”
- GeoAlchemy2GeoAlchemy2 extends SQLAlchemy to work with spatial databases,…
- pygeofilterParses OGC filtering standards (CQL, CQL JSON, JFE, FES) into an…
- rtreeRtree wraps libspatialindex to provide spatial indexing for Python,…
Give your agent the search over MCP, or paste the wish link into any chat.
More GIS packages
Shapely provides Python tools for creating, manipulating, and analyzing 2D geometric objects (points, lines, polygons) using the GEOS library, with both scalar and vectorized NumPy-based operations.
pyproj provides a Python interface to PROJ, enabling cartographic projections and coordinate system transformations for geospatial applications.
GeoPandas extends pandas DataFrames to handle geographic data, combining pandas operations with shapely geometry and spatial analysis capabilities that would otherwise require a spatial database.
Install it if you work with geographic data in Python and want to avoid setting up a spatial database or learning a separate GIS tool.
geopy is a Python client for geocoding and distance calculation that converts addresses to coordinates and vice versa using multiple web-based geocoding services, and computes geodesic and great-circle distances between geographic points.
Install it if you need geocoding or distance calculations in your application.
Pyogrio provides fast, bulk-oriented read and write access to vector spatial data formats (Shapefile, GeoPackage, GeoJSON, etc.) via GDAL/OGR bindings, typically for use with GeoPandas GeoDataFrames.
h3 provides Python bindings to Uber's H3 geospatial indexing library, converting geographic coordinates into hierarchical hexagonal grid cells and performing spatial operations on them.
See also SQLAlchemy · pygeofilter · osmium · sqlalchemy-jdbcapi · geodatasets · geoarrow-c · Flask-SQLAlchemy · sqlalchemy-firebird · cmeel-octomap