You will notice that the SQLModel example is very similar to the SQLAlchemy example for fastapi-users. This is because SQLModel is built on top of SQLAlchemy and pydantic.
There are a few important differences you should take note of:
| #!/usr/bin/env python | |
| from os import environ | |
| from re import compile | |
| from yaml import SafeLoader, load | |
| def yml(path=None, data=None, tag=None): | |
| """ |
| #!/usr/bin/env python | |
| import logging | |
| from os import environ | |
| def logger(level="info", timestamp=True, filename=None, | |
| custom_format=None, inherit_env=True): | |
| """ | |
| Default Logging Method. This takes multiple |
| #!/usr/bin/env python3 | |
| # Author:: Justin Flannery (mailto:[email protected]) | |
| """ | |
| State Machine Example. | |
| """ | |
| import logging | |
| from enum import Enum |
| #!/usr/bin/env python3 | |
| # Author:: Justin Flannery (mailto:[email protected]) | |
| """ | |
| An Easy Script for Retrieving the Percent Through the Current Month | |
| """ | |
| from calendar import monthrange | |
| from datetime import datetime |
| """ | |
| Reproducible Cohorting for Experiments | |
| """ | |
| import hashlib | |
| import logging | |
| from typing import Dict, Optional, Tuple | |
| import numpy as np | |
| from pandas import DataFrame |
| """ | |
| Custom JSON Encoding | |
| Thanks Pydantic! https://github.com/samuelcolvin/pydantic/blob/master/pydantic/json.py | |
| """ | |
| from collections import deque | |
| from dataclasses import asdict, is_dataclass | |
| import datetime | |
| from decimal import Decimal |
| """ | |
| Extending the SimpleNamespace Class | |
| """ | |
| import datetime | |
| from functools import singledispatch | |
| from types import SimpleNamespace | |
| from typing import Any | |
| #!/usr/bin/env python3 | |
| """ | |
| AWS Profile Rotation Script | |
| """ | |
| import argparse | |
| import configparser | |
| import pathlib | |
| from copy import deepcopy |
You will notice that the SQLModel example is very similar to the SQLAlchemy example for fastapi-users. This is because SQLModel is built on top of SQLAlchemy and pydantic.
There are a few important differences you should take note of:
| from typing import Literal, TypedDict | |
| DENSE_CALCIUM_VOLUME: Literal["denseCalciumVolume"] = "denseCalciumVolume" | |
| FATTY_FIBROUS_VOLUME: Literal["fattyFibrousVolume"] = "fattyFibrousVolume" | |
| TOTAL_CALCIFIED_PLAQUE_VOLUME = "totalCalcifiedPlaqueVolume" | |
| class TypedCleerlyDict(TypedDict): | |
| denseCalciumVolume: float | |
| fattyFibrousVolume: float |