Created
October 25, 2022 04:40
-
-
Save iisaka51/7e39f6da66047e86b860717ed5f6cdd0 to your computer and use it in GitHub Desktop.
users class with aDict
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
In [1]: from datajuggler import serializer as io | |
In [2]: from datajuggler import aDict | |
In [3]: class User(aDict): | |
...: pass | |
...: | |
In [4]: users = io.read_contents('sqlite:///users.sqlite#users',row_type=User) | |
In [5]: users | |
Out[5]: | |
[User({'id': 1, 'name': 'David Coverdale', 'age': 71, 'belongs': 'Whitesnake'}), | |
User({'id': 2, 'name': 'Neal Schon ', 'age': 68, 'belongs': 'Journey'}), | |
User({'id': 3, 'name': 'Tom Scholz', 'age': 75, 'belongs': 'Boston'}), | |
User({'id': 4, 'name': 'David Gilmour', 'age': 75, 'belongs': 'Pink Floyd'}), | |
User({'id': 5, 'name': 'Ann Wilson', 'age': 71, 'belongs': 'Heart'}), | |
User({'id': 6, 'name': 'Nacy Wilson', 'age': 67, 'belongs': 'Heart'})] | |
In [6]: users[0].name | |
Out[6]: 'David Coverdale' | |
In [7]: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment