Skip to content

A timezone error on python3.12 and alembic[tz]? #1556

@Danipulok

Description

@Danipulok

Describe the bug
Async API mode.
I used config templates from here.
I used pip install alembic[tz]:

$ pip install alembic[tz]==1.13.3
Requirement already satisfied: alembic==1.13.3 in d:\code\project\.venv\lib\site-packages (from alembic[tz]==1.13.3) (1.13.3)
Requirement already satisfied: SQLAlchemy>=1.3.0 in d:\code\project\.venv\lib\site-packages (from alembic==1.13.3->alembic[tz]==1.13.3) (2.0.36)
Requirement already satisfied: Mako in d:\code\project\.venv\lib\site-packages (from alembic==1.13.3->alembic[tz]==1.13.3) (1.3.6)
Requirement already satisfied: typing-extensions>=4 in d:\code\project\.venv\lib\site-packages (from alembic==1.13.3->alembic[tz]==1.13.3) (4.12.2)
Requirement already satisfied: greenlet!=0.4.17 in d:\code\project\.venv\lib\site-packages (from SQLAlchemy>=1.3.0->alembic==1.13.3->alembic[tz]==1.13.3) (3.1.1)     
Requirement already satisfied: MarkupSafe>=0.9.2 in d:\code\project\.venv\lib\site-packages (from Mako->alembic==1.13.3->alembic[tz]==1.13.3) (3.0.2)

But when I run alembic revision --autogenerate -m "msg", I get:

INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.autogenerate.compare] Detected added table 'users'
INFO  [alembic.autogenerate.compare] Detected added index ''ix_users_created_at'' on '('created_at',)'
ERROR [alembic.util.messaging] Can't locate timezone: UTC
FAILED: Can't locate timezone: UTC

Expected behavior
Everything should work if I installed alembic[tz]?
But I also found this issue on SO: https://stackoverflow.com/questions/77698777/how-to-change-timezone-in-alembic-for-sqlalchemy
After I install tzdata, the same command stated working.

To Reproduce
Use this alembic.ini: https://github.com/sqlalchemy/alembic/blob/bd50ba325b10a1a9cdb452fe40c96f959825797c/alembic/templates/async/alembic.ini.mako
And add:

timezone = UTC

Versions.

  • OS: Windows 10
  • Python: 3.12.3
  • Alembic: 1.13.3
  • SQLAlchemy: 2.0.36
  • Database: postgres
  • DBAPI: asyncpg==0.30.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinguse casenot quite a feature and not quite a bug, something we just didn't think of

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions