sqlalchemy-neon-serverless
A SQLAlchemy dialect for Neon's serverless HTTP endpoint. Sends all SQL over HTTPS — no TCP connection, no psycopg2, no asyncpg.
This is useful when:
- You're behind a corporate proxy that blocks PostgreSQL TCP connections (port 5432)
- You're running in a serverless environment (Lambda, Cloud Functions, Edge) where persistent connections aren't practical
- You want to use SQLModel or SQLAlchemy ORM with Neon without installing native PostgreSQL drivers
How it works
SQLAlchemy Engine (postgresql+neonserverless://)
└── NeonServerlessDialect (extends PGDialect)
└── DBAPI 2.0 Module (PEP 249)
└── httpx POST → https://{host}/sql
Each SQL statement is sent as an HTTP POST to Neon's /sql endpoint. Every request auto-commits. The DBAPI module handles parameter conversion from SQLAlchemy's %s format to Neon's $1, $2, ... positional format.
Installation
pip install sqlalchemy-neon-serverless
# Or with uv
uv add sqlalchemy-neon-serverless
# With SQLModel support
pip install sqlalchemy-neon-serverless[sqlmodel]
Usage
SQLAlchemy Core
from sqlalchemy import create_engine, text
engine = create_engine("postgresql+neonserverless://user:pass@ep-cool-123.neon.tech/mydb")
with engine.connect() as conn:
result = conn.execute(text("SELECT * FROM users WHERE id = :id"), {"id": 1})
print(result.fetchone())
SQLAlchemy ORM
from sqlalchemy import create_engine, Column, String
from sqlalchemy.orm import DeclarativeBase, Session
engine = create_engine("postgresql+neonserverless://user:pass@ep-cool-123.neon.tech/mydb")
class Base(DeclarativeBase):
pass
class User(Base):
__tablename__ = "users"
id = Column(String, primary_key=True)
name = Column(String)
with Session(engine) as session:
users = session.query(User).all()
SQLModel
from sqlmodel import Field, Session, SQLModel, create_engine, select
engine = create_engine("postgresql+neonserverless://user:pass@ep-cool-123.neon.tech/mydb")
class User(SQLModel, table=True):
id: str = Field(primary_key=True)
name: str
with Session(engine) as session:
users = session.exec(select(User)).all()
Connection URL format
postgresql+neonserverless://user:password@endpoint-host.neon.tech/dbname
The dialect automatically:
- Strips the
-poolersuffix from the hostname (Neon HTTP API requires the non-pooler host) - Constructs the
Neon-Connection-Stringheader - Sends queries to
https://{host}/sql
Environment variables
| Variable | Description |
|---|---|
SSL_CERT_FILE |
Path to CA bundle for TLS verification. Set to "" to disable verification (corporate proxy). |
Limitations
- No transactions: Each HTTP request auto-commits.
session.rollback()is a no-op. - No server-side cursors: All results are fetched in a single HTTP response.
- No streaming: Large result sets are fully loaded into memory.
- No LISTEN/NOTIFY: WebSocket-based features are not supported.
Inspired by
- sqlalchemy-aurora-data-api — SQLAlchemy dialect for AWS Aurora Data API (same pattern: SQL over HTTP)
- @neondatabase/serverless — Official Neon TypeScript serverless driver
License
MIT
Metadata
Release files for sqlalchemy-neon-serverless 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sqlalchemy_neon_serverless-0.1.0.tar.gz | 6.7 kB | Without provenance | Details for sqlalchemy_neon_serverless-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sqlalchemy_neon_serverless-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for sqlalchemy_neon_serverless-0.1.0-py3-none-any.whl |
Total release size: 17.9 kB
Release files / sqlalchemy_neon_serverless-0.1.0.tar.gz
| Download URL | sqlalchemy_neon_serverless-0.1.0.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
78dcaee34b49385f8204958b4b389e2a3ca400e51c75e3793f604e8c4b0888b7
|
|
BLAKE2b-256 checksum How to use checksums |
58cac0fc48251a9a51df4a00e93cf84be01350dc16a5ae2f1f44593e3da835c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / sqlalchemy_neon_serverless-0.1.0-py3-none-any.whl
| Download URL | sqlalchemy_neon_serverless-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bf60ad67c0bc68eed22f51952643bbbf3d83d23b7e65cf6e6828886200c5eb8a
|
|
BLAKE2b-256 checksum How to use checksums |
6a9c1df5559ed2c9188566e0a75f761b20d09b7b109cb9766ad8b15fa1f6dd10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for sqlalchemy-neon-serverless 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.