am a newbie ..
encountered a small problem
any help will be appreciated

class Stock(declarative_base):
      __tablename__ = 'tbl_stock'
      ....
      ....
      books = relation("Book", order_by="Book.id",
backref="tbl_stock")
      ....
      pass

class Book(declarative_base):
      __tablename__ = 'tbl_books'
      ....
      ....
      stock = relation('Stock', backref=backref('tbl_books',
order_by=id))

## created a stock and added 3 books to the stock
ins_stock = Stock()
ins_book_1 = Book('Book1')
ins_book_2 = Book('Book2')
ins_book_3 = Book('Book3')
ins_stock.books = [ins_book_1,ins_book_2,ins_book_3]

# saving .......
session.add(ins_stock)
flush()

#  Later when i update the stock like removing book1 and adding book4
# book1 exists in the db

ins_stock.books.remove(ins_book_1)
ins_book_4 = Book('Book4')
ins_stock.books.add(ins_book_4)

flush()

in the table the row corresponding to the book1 remains there
what should i do to tell sqlalchemy to automatically remove orphan
books
i have tried giving cascade = 'a'',delete-orphan'
but errors comes

thanks and regards
[EMAIL PROTECTED]
Calicut,India

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to