You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running the code as instructed throws an AttributeError:
2022-05-19 10:57:57,546 INFO sqlalchemy.engine.Engine BEGIN (implicit)
2022-05-19 10:57:57,546 INFO sqlalchemy.engine.Engine PRAGMA main.table_info("team")
2022-05-19 10:57:57,546 INFO sqlalchemy.engine.Engine [raw sql] ()
2022-05-19 10:57:57,547 INFO sqlalchemy.engine.Engine PRAGMA main.table_info("hero")
2022-05-19 10:57:57,547 INFO sqlalchemy.engine.Engine [raw sql] ()
2022-05-19 10:57:57,547 INFO sqlalchemy.engine.Engine COMMIT
2022-05-19 10:57:57,547 INFO sqlalchemy.engine.Engine BEGIN (implicit)
2022-05-19 10:57:57,548 INFO sqlalchemy.engine.Engine INSERT INTO hero (name, secret_name, age, team_id) VALUES (?, ?, ?, ?)
2022-05-19 10:57:57,548 INFO sqlalchemy.engine.Engine [generated in 0.00006s] ('Deadpond', 'Dive Wilson', None, None)
2022-05-19 10:57:57,548 INFO sqlalchemy.engine.Engine INSERT INTO hero (name, secret_name, age, team_id) VALUES (?, ?, ?, ?)
2022-05-19 10:57:57,548 INFO sqlalchemy.engine.Engine [cached since 0.0004535s ago] ('Rusty-Man', 'Tommy Sharp', 48, None)
2022-05-19 10:57:57,549 INFO sqlalchemy.engine.Engine INSERT INTO hero (name, secret_name, age, team_id) VALUES (?, ?, ?, ?)
2022-05-19 10:57:57,549 INFO sqlalchemy.engine.Engine [cached since 0.0005178s ago] ('Spider-Boy', 'Pedro Parqueador', None, None)
2022-05-19 10:57:57,549 INFO sqlalchemy.engine.Engine COMMIT
2022-05-19 10:57:57,550 INFO sqlalchemy.engine.Engine BEGIN (implicit)
2022-05-19 10:57:57,551 INFO sqlalchemy.engine.Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id
FROM hero
WHERE hero.id = ?
2022-05-19 10:57:57,551 INFO sqlalchemy.engine.Engine [generated in 0.00007s] (7,)
2022-05-19 10:57:57,551 INFO sqlalchemy.engine.Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id
FROM hero
WHERE hero.id = ?
2022-05-19 10:57:57,551 INFO sqlalchemy.engine.Engine [cached since 0.0005488s ago] (8,)
2022-05-19 10:57:57,551 INFO sqlalchemy.engine.Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id
FROM hero
WHERE hero.id = ?
2022-05-19 10:57:57,551 INFO sqlalchemy.engine.Engine [cached since 0.0007544s ago] (9,)
Created hero: name='Deadpond' team_id=None secret_name='Dive Wilson' id=7 age=None
Created hero: name='Rusty-Man' team_id=None secret_name='Tommy Sharp' id=8 age=48
Created hero: name='Spider-Boy' team_id=None secret_name='Pedro Parqueador' id=9 age=None
2022-05-19 10:57:57,551 INFO sqlalchemy.engine.Engine COMMIT
2022-05-19 10:57:57,552 INFO sqlalchemy.engine.Engine BEGIN (implicit)
2022-05-19 10:57:57,552 INFO sqlalchemy.engine.Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id
FROM hero
WHERE hero.id = ?
2022-05-19 10:57:57,552 INFO sqlalchemy.engine.Engine [cached since 0.001206s ago] (9,)
Updated hero: name='Spider-Boy' team_id=None secret_name='Pedro Parqueador' id=9 age=None
2022-05-19 10:57:57,552 INFO sqlalchemy.engine.Engine INSERT INTO team (name, headquarters) VALUES (?, ?)
2022-05-19 10:57:57,552 INFO sqlalchemy.engine.Engine [generated in 0.00006s] ('Wakaland', 'Wakaland Capital City')
2022-05-19 10:57:57,553 INFO sqlalchemy.engine.Engine COMMIT
2022-05-19 10:57:57,553 INFO sqlalchemy.engine.Engine BEGIN (implicit)
2022-05-19 10:57:57,554 INFO sqlalchemy.engine.Engine SELECT team.id, team.name, team.headquarters
FROM team
WHERE team.id = ?
2022-05-19 10:57:57,554 INFO sqlalchemy.engine.Engine [generated in 0.00006s] (3,)
Team Wakaland: name='Wakaland' headquarters='Wakaland Capital City' id=3
2022-05-19 10:57:57,554 INFO sqlalchemy.engine.Engine ROLLBACK
Traceback (most recent call last):
File "/Users/marcel/test_sqlmodel/test.py", line 104, in <module>
main()
File "/Users/marcel/test_sqlmodel/test.py", line 98, in main
create_heroes()
File "/Users/marcel/test_sqlmodel/test.py", line 83, in create_heroes
team_preventers.heroes.append(hero_tarantula)
AttributeError: 'Team' object has no attribute 'heroes'
Operating System
macOS
Operating System Details
No response
SQLModel Version
0.0.6
Python Version
3.10.4
Additional Context
No response
The text was updated successfully, but these errors were encountered:
@tiangolo I Checked it with python 3.10, 3.9 and 3.8, all throwing the same error. I always use a clean new venv created with poetry, so there are no conflicts with other packages.
The packages that get installed are:
typing-extensions (4.2.0)
pydantic (1.9.0)
sqlalchemy (1.4.36)
sqlalchemy2-stubs (0.0.2a22)
sqlmodel (0.0.6)
Maybe there are some breaking changes in sqlalchemy or pydantic, so we need to lock down the version requirements more tightly?
First Check
Commit to Help
Example Code
Description
Official Code Example from https://sqlmodel.tiangolo.com/tutorial/relationship-attributes/create-and-update-relationships/#include-relationship-objects-in-the-many-side
Running the code as instructed throws an AttributeError:
Operating System
macOS
Operating System Details
No response
SQLModel Version
0.0.6
Python Version
3.10.4
Additional Context
No response
The text was updated successfully, but these errors were encountered: