A more complete example
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import *
Base = declarative_base()
class Item(Base):
__tablename__ = 'item'
id = Column(Integer, primary_key=True)
type = Column(String)
__mapper_args__ = {
'polymorphic_on': type,
A more complete example:
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import *
Base = declarative_base()
class Item(Base):
__tablename__ = 'item'
id = Column(Integer, primary_key=True)
type = Column(String)
__mapper_args__ = {
'polymorphic_on': type,
Hi---
I set out about 20 minutes ago to learn SQLAlchemy, and the third hit
Google gave me was the Object Relational Tutorial:
http://docs.sqlalchemy.org/en/latest/orm/tutorial.html
Where I stalled on the second sentence of the second paragraph, the
intended meaning of which I cannot
This is referencing a concept in software design termed "opinionated".
Do a search for "opinionated framework" or "opinionated software" and this
will all probably make sense.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example
I have a self referential polymorphic relationship using single table
inheritance
Base = declarative_base()
class Item(Base):
__tablename__ = 'item'
id = Column(Integer)
type = Column(String)
__mapper_args__ = { 'polymorphic_on': type, 'with_polymorphic': '*'}
class
I'm keying off hasattr(obj, 'keys') which is working. Still seems strange
that it is returning a non-exported class though.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and
On Mon, Apr 24, 2017 at 10:26 PM, Jonathan Vanasco
wrote:
>
> On Monday, April 24, 2017 at 4:28:22 PM UTC-4, Mike Bayer wrote:
>>
>> yeah just load the object again w/ the eagerloads option you want.
>
>
>
> Thanks. I was hoping there was a way to just say
On Tuesday, April 25, 2017 at 5:50:48 AM UTC-4, Simon King wrote:
>
> def reload(instance, *options):
> session = saorm.object_session(instance)
> # TODO: make this generic rather than assuming presence of 'id' column
> q = (session.query(type(instance))
>