return Column(Integer)
class ARefClass(RefClass):
ref = AClass
class BRefClass(RefClass):
ref = BClass
engine = create_engine('sqlite://', echo=True)
Base.metadata.bind = engine
Base.metadata.create_all()
db = Session(engine)
Thanks!
Devin
--
SQLAlchemy -
The Python SQL Too
First, thanks for your very insightful response. I'm trying to reproduce
what you've provided, but I'm getting an `InvalidRequestError` when
querying on `RefClass`:
*InvalidRequestError: SQL expression, column, or mapped entity expected -
got ''*
Indeed, RefClass has no `__mapper__` attribute.
Yep. That's solves it. Thanks again for your help.
--
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://stackoverflow.com/help/mcve for a full descri
constructing this? I'm trying to generalize this, so I'd
also like to be able to do this same query on a One-to-Many mapping too
(where B.a_id = Column(Integer, ForeignKey('amodels.id'))).
Thanks!
Devin
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
htt
p of sqlalchemy.core (perhaps with something like
`aiopg`), or whether there is a pattern I'm missing?
Thanks,
Devin
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifi
from sqlalchemy import Column, and_
from sqlalchemy import create_engine, Integer, String, Date, Enum
from sqlalchemy.orm import sessionmaker, relationship, remote, foreign
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.exc import DataError, IntegrityError
Base = declar
I'm going to link the docs for easy reference for any future readers:
http://docs.sqlalchemy.org/en/latest/orm/self_referential.html?highlight=join_depth#configuring-self-referential-eager-loading
I ended up using something link
session.query(Game).options(joinedload(Game.opp))
because I didn'