File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -60,9 +60,9 @@ But they are not yet in the database, so let's make sure they are::
60
60
Accessing the data in database is easy as a pie::
61
61
62
62
>>> User.query.all()
63
- [<User u 'admin'>, <User u 'guest'>]
63
+ [<User 'admin'>, <User 'guest'>]
64
64
>>> User.query.filter_by(username='admin').first()
65
- <User u 'admin'>
65
+ <User 'admin'>
66
66
67
67
Note how we never defined a ``__init__ `` method on the ``User `` class?
68
68
That's because SQLAlchemy adds an implicit constructor to all model
@@ -143,8 +143,8 @@ load all categories and their posts, you could do it like this::
143
143
>>> from sqlalchemy.orm import joinedload
144
144
>>> query = Category.query.options(joinedload('posts'))
145
145
>>> for category in query:
146
- ... print category, category.posts
147
- <Category u 'Python'> [<Post u 'Hello Python!'>, <Post u 'Snakes'>]
146
+ ... print( category, category.posts)
147
+ <Category 'Python'> [<Post 'Hello Python!'>, <Post 'Snakes'>]
148
148
149
149
150
150
If you want to get a query object for that relationship, you can do so
You can’t perform that action at this time.
0 commit comments