Last active
November 15, 2021 08:21
-
-
Save codemation/5caf613974d196acf641cd7371e4725c to your computer and use it in GitHub Desktop.
pydbantic_model_0.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# models.py | |
import uuid | |
from datetime import datetime | |
from typing import Optional | |
from pydbantic import DataBaseModel, PrimaryKey, Default | |
def time_now_str(): | |
return datetime.now().isoformat() | |
def stringify_uuid(): | |
return str(uuid.uuid4()) | |
class Employee(DataBaseModel): | |
id: str = PrimaryKey(default=stringify_uuid) | |
salary: float | |
is_employed: bool | |
date_employed: str = Default(default=time_now_str) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment