python - What type is on the other end of relation in sqlalchemy without creating objects? -


How to get the square name on the other end of the relationship? It was declared during the relationship, I think the information should be somewhere in sqlalchemy.orm.util.class_mapper

Suppose that we have a relation between these three categories and the two. Book * --- 1 shelf and book * --- * Author

  class shelf (base): __tablename__ = 'shelves' id = column (integer, primary_key = true) name = column ( String) #backref in Book.shelf def __init __ (self, name = "") - Multiple books by: self.name = name class book (base): __tablename__ = 'books' id = column (integer, primary_key = True) Title = column (strings) # Many-to-one shelf shelf_id = column (integer, foreign ('shelves.' '')) Shelf = connection (shelf, backfreaf = backfif ('books' Id = ""): self.title = title, author_book = table ('author_book', 'metadata', column ('author_id', integer, foreigner '(author.id')), Column ('book_id', integer, foreign ('books.id')) class author (base): __tablename__ = 'authors' id = column (integer, primary_key = true) name = column (string) # many -Many books books = relations ship ('book', secondary = writer_book, backf = 'writers') def __init __ (self, name = ""): self.name = name  

class_mapper (class) .iterate_properties We can easily get different properties: Column property and relationship property should be a way of obtaining a leat on the name of that class in the relat. any idea?

Probably a little nipper solution.

  for support in class_mapper (shelf). CoreyProperties: If ESTENCE (PROP, SCLESSMI. RELIANCE PROPERTY): PRINT PROMAPER. Class_  

works with one-to-many and many-to-many directions


Comments