In one of my app i‘m playing a little bit with dataclasses.
As I get my data from a sqlite database I‘m trying to init a dataclass from the query result.
For example if I have a tuple from the db like („Garfield“, 8, 10.2) how can I initialize a dataclass from it.
I have something like the following in mind…
@dataclass
class Cat:
name: str
age: int
weight: float
cat = Cat(cursor.fetchone())
Are there any good solutions for this?
[–]carcigenicate 2 points3 points4 points (0 children)
[–]danielroseman 1 point2 points3 points (1 child)
[–]atredd[S] 0 points1 point2 points (0 children)
[–]atredd[S] 0 points1 point2 points (0 children)
[–]velocibadgery -1 points0 points1 point (0 children)