Re: [sqlalchemy] Defining model.py for existing database

2020-12-18 Thread Larry Martell
You can use the sqlacodegen tool for generating models from an existing schema. https://pypi.org/project/sqlacodegen/ On Fri, Dec 18, 2020 at 3:41 PM Rich Shepard wrote: > > I'm working on learning SQLAlchemy to use for my business tracking > application. I have the views written (in tkinter) an

[sqlalchemy] Defining model.py for existing database

2020-12-18 Thread Rich Shepard
I'm working on learning SQLAlchemy to use for my business tracking application. I have the views written (in tkinter) and two versions of model.py as the model. Long ago I asked about using base or declarative base but no longer have that thread saved. I've read about base mapping and declarative

Re: [sqlalchemy] One to One relation problem [re-open?]

2020-12-18 Thread 'Sören Textor' via sqlalchemy
Ah. I see. Thus this was a newbie question. Thanks again! Mike Bayer schrieb am Fr. 18. Dez. 2020 um 19:44: > hey there - > > you can assign the "id" but that doesn't give SQLAlchemy any clue that you > are working with the "daughter" relationship so it doesn't know to > deassociate m2.daughter.

Re: [sqlalchemy] One to One relation problem [re-open?]

2020-12-18 Thread Mike Bayer
hey there - you can assign the "id" but that doesn't give SQLAlchemy any clue that you are working with the "daughter" relationship so it doesn't know to deassociate m2.daughter. You'll note that relationally, there's no issue as from a foreign key perspective Mama->daughter is many to one. S

Re: [sqlalchemy] One to One relation problem [re-open?]

2020-12-18 Thread 'Sören Textor' via sqlalchemy
This example fails. Instead of assigning an objekt, I assign just the daughters id ... But I think that's "correct"? from sqlalchemy import Column from sqlalchemy import create_engine from sqlalchemy import ForeignKey from sqlalchemy import Integer from sqlalchemy.ext.declarative import declarat

[sqlalchemy] Re: One to One relation problem [solved]

2020-12-18 Thread 'Sören Textor' via sqlalchemy
Hi Mike Thanks for looking at my code. Next time I'll post an testcase like you. Sorry for that one. And I cannot believe it. But it works now. I also updated SQLAlchemy, flast-RESTful, flask-migrate and so on, to their newest version. And now it seems to work. And problem before was > assert

Re: [sqlalchemy] One to One relation problem

2020-12-18 Thread Mike Bayer
hey there - these mappings are pretty good, as is always the case I cannot predict why an issue is occurring, or usually even understand the issue, without running the code. your code is pretty runnable with a few imports added so that's great. however adding an assertion for the condition y

Re: [sqlalchemy] Re: Can't delete cascade many-to-many with polymorphic relationships unless using lazy=dynamic

2020-12-18 Thread Mike Bayer
your example shows two relationships to the identical target class: children = relationship( "ChildChildClass", secondary="mix_child_class_child_child_class", cascade="all, delete", ) children2 = relationship( "ChildChildClass", secondary="mix_ch

Re: [sqlalchemy] Re: Can't delete cascade many-to-many with polymorphic relationships unless using lazy=dynamic

2020-12-18 Thread Mark Aquino
Thanks. That could work. The reason we need specific relationships to the child class types is for our front end when it queries the data, which we use sqlalchemy-graphene to do, if we query the base class relationship it returns empty rows and makes pagination impossible as the front end is una