Skip to content

Instantly share code, notes, and snippets.

@iisaka51
Created October 25, 2022 04:26
Show Gist options
  • Save iisaka51/533b928bb9bd996666273493c9036155 to your computer and use it in GitHub Desktop.
Save iisaka51/533b928bb9bd996666273493c9036155 to your computer and use it in GitHub Desktop.
users_class not define __repr__
In [4]: class User:
...:
...: def __init__(self, *nargs, **kwargs):
...: self.data = dict(*nargs, **kwargs)
...: self.id: int = self.data['id']
...: self.name: str = self.data['name']
...: self.age: int = self.data['age']
...: self.belongs: str = self.data['belongs']
...:
In [5]: io.read_contents('sqlite:///users.sqlite#users',row_type=User)
Out[5]:
[<__main__.User at 0x1092c0f40>,
<__main__.User at 0x1092c3430>,
<__main__.User at 0x1092c0cd0>,
<__main__.User at 0x1092c1d20>,
<__main__.User at 0x1092c26e0>,
<__main__.User at 0x1092c1660>]
In [6]:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment