Re: [sqlalchemy] Issue with "complex" many 2 many delete, FK violation

2021-04-13 Thread Mark Aquino
Hi Mike, Sorry about the indentations. I'm not sure I understand the changes you made to the script after delete as it removes all test_chains, test_var_regions, and test_const regions that are still referenced by the other test_molecules. The only way I've been able to get the delete to work

Re: [sqlalchemy] Issue with "complex" many 2 many delete, FK violation

2021-04-13 Thread Mike Bayer
Hi there - I would ask that you try to make sure your formatting is maintained when posting examples especially such long ones as I had to re-indent it in order to run this. The delete at the end is failing because of incomplete cascade rules. The DELETE against "test_mol_sequence" seeks to

Re: [sqlalchemy] Issue with "complex" many 2 many delete, FK violation

2021-04-13 Thread Mark Aquino
I just wanted to clarify, the desire would be for the "test_var_region" and "test_const_region" entities that are linked to other entities to remain untouched and only to have their associations removed from the deleted items. The output from the ORM indicates that the system is actually

[sqlalchemy] Issue with "complex" many 2 many delete, FK violation

2021-04-13 Thread maqui...@gmail.com
I need to delete the association table rows for many to many relationships when I delete one, but the default behavior (to remove those rows) does not seem to work in my case. I have multiple levels of many to many relationships, as you can see in the example I'll provide below and when I

Re: [sqlalchemy] How to refer to columns whose names begin with a number when autoloading?

2021-04-13 Thread Mike Bayer
the next section at https://docs.sqlalchemy.org/en/14/orm/mapping_columns.html#automating-column-naming-schemes-from-reflected-tables shows how to automate intercepting of reflected columns, so you could do this: from sqlalchemy import event @event.listens_for(metadata, "column_reflect") def

Re: [sqlalchemy] How to refer to columns whose names begin with a number when autoloading?

2021-04-13 Thread r...@rosenfeld.to
Thanks for the documentation. Sorry, but I'm not certain how to apply that in my case. Since I am mapping to an existing table, how could I reference the object attribute with an illegal name in Python? Do I combine getattr with the documentation as below? class Student(Model):

Re: Re[4]: [sqlalchemy] Invertinace mapped type_id to fix value for each child class

2021-04-13 Thread Simon King
I probably wouldn't use this: if test_type == ChildClass1().typ_id: ...simply because creating an instance of the object just to get access to the typ_id seems like a waste of effort. If you really need to check integer typ_id values, the staticmethod approach seems fine. Simon On Mon, Apr