whenever-sqlalchemy
SQLAlchemy column types for the whenever datetime library.
Installation
pip install whenever-sqlalchemy
Type mapping
| whenever type | SQL type |
|---|---|
Instant |
TIMESTAMP WITH TIME ZONE |
PlainDateTime |
TIMESTAMP (no timezone) |
Date |
DATE |
Time |
TIME |
Usage
SQLAlchemy 2.x — Mapped[] style (recommended)
Register type_annotation_map on your DeclarativeBase once, then use
Mapped[Instant] exactly like you would use Mapped[datetime]:
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
from whenever import Date, Instant, PlainDateTime, Time
from whenever_sqlalchemy import type_annotation_map
class Base(DeclarativeBase):
type_annotation_map = type_annotation_map # merge with your own if needed
class Event(Base):
__tablename__ = "events"
id: Mapped[int] = mapped_column(primary_key=True)
timestamp: Mapped[Instant]
scheduled: Mapped[PlainDateTime | None]
date: Mapped[Date | None]
time: Mapped[Time | None]
SQLAlchemy 1.4 / 2.x — Column() style
from sqlalchemy import Column, Integer
from whenever_sqlalchemy import DateType, InstantType, PlainDateTimeType, TimeType
class Event(Base):
__tablename__ = "events"
id = Column(Integer, primary_key=True)
timestamp = Column(InstantType)
scheduled = Column(PlainDateTimeType, nullable=True)
date = Column(DateType, nullable=True)
time = Column(TimeType, nullable=True)
Notes
Nanoseconds — whenever types support nanosecond precision; SQL
TIMESTAMP columns store at most microsecond precision. Values are
truncated (not rounded) to microseconds on write, matching to_stdlib().
server_default — server_default=func.now() works as expected: the
server sets the value and SQLAlchemy fetches it back, converting it to the
appropriate whenever type.
Dialect notes
- PostgreSQL: uses
TIMESTAMPTZnatively; full roundtrip fidelity. - SQLite: stores datetimes as text and drops timezone info.
InstantTypereattaches UTC tzinfo on retrieval (the stored value is UTC). - MySQL / MariaDB / SQL Server: similar to SQLite for timezone columns; the UTC-reattach workaround covers these too.
Compatibility
- Python 3.10+
- whenever 0.10+
- SQLAlchemy 1.4+ (
Column()style); SQLAlchemy 2.0+ (Mapped[]style)
Metadata
Release files for whenever-sqlalchemy 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 | |
|---|---|---|---|
| whenever_sqlalchemy-0.1.0.tar.gz | 6.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| whenever_sqlalchemy-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.6 kB
Release files / whenever_sqlalchemy-0.1.0.tar.gz
| Download URL | whenever_sqlalchemy-0.1.0.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0f37dde4efd061da089c942e62d73639ede216922b6cb0f0ac76f9d5beb98b7d
|
|
BLAKE2b-256 checksum How to use checksums |
db2dc3c7e6224482d7a3a531f73926b323a76f199ce6b50ce16f4fb123261ae5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 5, 2026.
Transparency logRelease files / whenever_sqlalchemy-0.1.0-py3-none-any.whl
| Download URL | whenever_sqlalchemy-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d134b30d52365542b15f14f898bb1c324e20afc59ad5ab69ea184ea63e04946
|
|
BLAKE2b-256 checksum How to use checksums |
fb51d5cc00014556e59aed4eb5889eb58ddf5c216900f8a7b5d7047b7ba9b732
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 5, 2026.
Transparency log