-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"""QualiCharge models utilities.""" | ||
|
||
from sqlmodel import SQLModel | ||
|
||
|
||
class ModelSchemaMixin: | ||
"""A mixin that adds Pydantic to SQLModel helpers.""" | ||
|
||
def get_fields_for_schema(self, schema: SQLModel): | ||
"""Get input schema-related fields/values as a dict.""" | ||
return self.model_dump(include=set(schema.model_fields.keys())) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"""QualiCharge schemas utilities.""" | ||
|
||
from sqlmodel import SQLModel | ||
|
||
from ..models.static import Statique | ||
|
||
|
||
def get_or_create(schema: SQLModel, **kwargs): | ||
"""Get or create schema instance.""" | ||
|
||
|
||
def save_statique(statique: Statique): | ||
"""Save Statique instance to database.""" |
This file contains 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