We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import datetime from typing import List, Optional import sqlmodel class AuthUser(sqlmodel.SQLModel, table=True): __tablename__ = 'auth_user' id: Optional[int] = sqlmodel.Field(default=None, primary_key=True) password: str = sqlmodel.Field(max_length=128) last_login: datetime.datetime
I'm trying to make the last_login field become a "timestamp with time zone" field in Postgres.
last_login
With the above code, it is a "timestamp without time zone".
Linux, macOS
No response
0.0.3
Python 3.8.1
The text was updated successfully, but these errors were encountered:
import datetime from typing import List, Optional import sqalchemy as sa import sqlmodel class AuthUser(sqlmodel.SQLModel, table=True): __tablename__ = 'auth_user' id: Optional[int] = sqlmodel.Field(default=None, primary_key=True) password: str = sqlmodel.Field(max_length=128) last_login: datetime.datetime = Field(sa_column=sa.Column(sa.DateTime(timezone=True), nullable=False))
Sorry, something went wrong.
Awesome, this was super helpful.
Since Column and DateTime are imported in sqlmodel, I modified it slightly as:
Column
DateTime
from typing import List, Optional import sqlmodel class AuthUser(sqlmodel.SQLModel, table=True): __tablename__ = 'auth_user' id: Optional[int] = sqlmodel.Field(default=None, primary_key=True) password: str = sqlmodel.Field(max_length=128) last_login: datetime.datetime = sqlmodel.Field( sa_column=sqlmodel.Column( sqlmodel.DateTime(timezone=True), nullable=False ) )
Nice. I kinda wish the pydantic fields (like EmailStr were also available in sqlmodel, so that everything is all in the same place) @tiangolo
EmailStr
sqlmodel
No branches or pull requests
First Check
Commit to Help
Example Code
Description
I'm trying to make the
last_login
field become a "timestamp with time zone" field in Postgres.With the above code, it is a "timestamp without time zone".
Operating System
Linux, macOS
Operating System Details
No response
SQLModel Version
0.0.3
Python Version
Python 3.8.1
Additional Context
No response
The text was updated successfully, but these errors were encountered: