Sorry I was not back sooner. Thank-you Simon King, you have solved my
problem. As anyone can guess I am still in the learning stages of
SqlAlchemy. My python/Sqlite solution has shown that I have neglected
SqlAlchemy core. When I first downloaded and studied SqlAlchemy, I only
glanced at th
SQLAlchemy normally presents a many-to-many relationship as a list on
both sides. You've got "Machine.children", which is a list of Options,
and "Option.parents", which is a list of Machines.
If you remove one of the options from a machine.children list, you'll
find that SQLAlchemy removes the ent
For the sake of completeness I am including the code to disconnect an
option from a machine using only python/SQLite code.
def removeOption(bladeKey, OptionKey):
"""
DELETE from blade_options
WHERE blade_FK == ?
AND options_FK == ?
"""
import sqlite3
dbPath = co
The situation is that I have two preloaded tables. The first is a Machine
to which one or more Options can be added. The second table has Options
can be connected to two or more machines. I've got the code to connect a
machine with an option but I can't devise the code to reverse the process
Thanks. IIRC, I think you just need to set a custom cascade on these
relationships (see https://docs.sqlalchemy.org/en/13/orm/cascades.html)
I am not sure which option that would be, because it sounds like your
application is behaving with a "delete-orphan", but that's not set.
--
SQLAlchemy -
full model for these 3 classes:
# machine
class Machine(Base):
__tablename__ = 'machine'
machine_ID = Column(Integer, primary_key=True)
machine_Type = Column(Integer, nullable=False)
machine_model = Column(String(10), nullable=False)
machine_Weight = Column(Integer)
m
Can you share the full model for these 3 classes, which includes the
relationship declarations?
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http:/