繁体   English   中英

在SQLAlchemy中完全加入?

[英]FULL JOIN in SQLAlchemy?

我想在预算应用中显示“最新条目”列表。 除user_id外,条目(如费用,收入,帐户转帐,贷款)具有不同的列。

在SQL中,我将进行FULL JOIN,但是我正在使用SQLAlchemy(声明性)。 这里正确的方法是什么? 一些元表?

非常感谢。

表格示例:

class Expense(Base):
    __tablename__ = 'expenses'
    id = Column(Integer, primary_key=True)
    user = Column('user_id', Integer, ForeignKey('users.id'))
    date = Column(Integer)
    category = Column('category_id', Integer, ForeignKey('expense_categories.id'))
    description = Column(String(50))
    deduct_from = Column('account_id', Integer, ForeignKey('accounts.id'))
    amount = Column(Float(precision=2))

class Loan(Base):
    __tablename__ = 'loans'
    id = Column(Integer, primary_key=True)
    from_user = Column('from_user_id', Integer, ForeignKey('users.id'))
    to_user = Column('to_user_id', Integer, ForeignKey('users.id'))
    date = Column(Integer)
    account = Column('account_id', Integer, ForeignKey('accounts.id'))
    description = Column(String(50))
    amount = Column(Float(precision=2)

如果您的数据库支持原始SQL,则必须使用原始SQL,否则将使用联合 来自http://groups.google.com/group/sqlalchemy/msg/80ea8e712380bff4

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM