sqlalchemy-spanner
SQLAlchemy dialect integrated into Cloud Spanner database
What it is and what it does
sqlalchemy-spanner is a SQLAlchemy dialect that bridges the gap between SQLAlchemy's ORM and query abstractions and Google Cloud Spanner's database engine. It wraps the Spanner DB API (which implements PEP-249) to allow developers to use familiar SQLAlchemy patterns—table definitions, insert/update/delete operations, and select queries—against a Spanner instance without writing raw SQL or using the lower-level Spanner client directly.
The dialect supports Spanner-specific features like interleaved tables, commit timestamps, and unique constraints, and integrates with Alembic for schema migrations. It requires active Google Cloud credentials and a configured Spanner project, instance, and database. The package depends on sqlalchemy, google-cloud-spanner, and alembic, and supports Python 3.10 through 3.14. However, the repository is archived and abandoned, with no commits since March 2026, which may pose risks for long-term maintenance and compatibility.
Use it for:
- Build a web application using SQLAlchemy ORM that persists data to Cloud Spanner without rewriting queries for a different database dialect.
- Migrate an existing SQLAlchemy application from a traditional SQL database to Cloud Spanner by swapping the connection URL.
- Define and manage Spanner schema using SQLAlchemy's declarative table API and Alembic migrations instead of raw DDL.
- Leverage Spanner's interleaved tables and commit-timestamp features through SQLAlchemy's table constructor options.
- Use SQLAlchemy's query builder and ORM relationships to work with Spanner data in a Python application.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a SQLAlchemy dialect that enables applications to use SQLAlchemy's ORM and query API against Google Cloud Spanner databases.
Yes, but with caution. The package is functional and has low install friction, but its abandoned status (no commits since March 2026) means no active maintenance or support for future SQLAlchemy or Spanner API changes. Install it only if you are committed to maintaining a fork or if your application's SQLAlchemy and Spanner dependencies are locked to versions known to work with this dialect. For new projects, verify whether a maintained alternative exists or whether direct use of the Spanner client is more appropriate.
Install
sqlalchemy-spanner on PyPI
pip
pip install sqlalchemy-spanneruv
uv add sqlalchemy-spannerpoetry
poetry add sqlalchemy-spannerInstalling sqlalchemy-spanner
Before you install
Low install friction with a pure-Python wheel. However, the package is marked as abandoned with no commits since 2026-03-13, raising concerns about future maintenance and compatibility with newer SQLAlchemy or Spanner API versions.
License in practice
Licensed under Apache 2.0 (permissive), allowing use in most commercial and open-source projects without significant restrictions.
Quickstart
pip install sqlalchemy-spanner
from sqlalchemy import create_engine, MetaData, Table
engine = create_engine(
"spanner+spanner:///projects/project-id/instances/instance-id/databases/database-id"
)
metadata = MetaData(bind=engine)
table = Table("users", metadata, autoload=True)
with engine.begin() as connection:
result = connection.execute(table.select())
Requires Google Cloud Spanner credentials configured via Application Default Credentials or passed explicitly; requires Python 3.10 or later.
Verify before relying
- Whether the abandoned status affects compatibility with current SQLAlchemy 2.x releases and recent Spanner API changes.
- Whether community forks or alternative maintained dialects exist for Spanner.
- Performance characteristics and known limitations beyond those listed in the documentation excerpt.
Package facts
| License | Apache 2.0 (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — sqlalchemy, google-cloud-spanner, alembic |
| Maintenance | abandoned — 72 days since the last release |
| Last repo commit | (repository archived) |
| First released | |
| Downloads | 19,731,216/month — #1,056 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: sqlalchemy_spanner-1.19.0-py3-none-any.whl
Tags
More Front-Ends packages
SQLAlchemy is a Python SQL toolkit and Object…
permissive · top 100 on PyPI
psycopg2-binarypsycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
alembicAlembic generates and manages database schema…
permissive · top 1,000 on PyPI
weaviate-clientA Python client library for connecting to and…
permissive · top 1,000 on PyPI
databricks-sql-connectorA Python client library that connects to…
permissive · top 1,000 on PyPI
psycopgPsycopg 3 is a PostgreSQL database adapter for…
copyleft · top 1,000 on PyPI
google-cloud-spannerPython client library for Google Cloud Spanner,…
permissive · top 1,000 on PyPI
sqlalchemy-solrProvides a SQLAlchemy dialect that allows you…
permissive · top 15,000 on PyPI
databricks-sqlalchemyProvides a SQLAlchemy 2.0 dialect that bridges…
permissive · top 1,000 on PyPI
clickhouse-sqlalchemySQLAlchemy dialect for ClickHouse that enables…
permissive · top 5,000 on PyPI
cerbos-sqlalchemyConverts Cerbos authorization query plans into…
permissive · top 15,000 on PyPI
pybigquerySQLAlchemy dialect for BigQuery that enables…
permissive · top 15,000 on PyPI
sqlalchemy-jdbcapiSQLAlchemy dialect for JDBC and ODBC database…
permissive · top 15,000 on PyPI
snowflake-sqlalchemySnowflake SQLAlchemy is a SQLAlchemy dialect…
permissive · top 1,000 on PyPI
db-dtypesProvides pandas extension data types for SQL…
permissive · top 1,000 on PyPI
sqlakeysetImplements keyset-based paging for SQLAlchemy…
permissive · top 5,000 on PyPI