On 2015-06-05 20:53 <[email protected]> wrote:
> How can I find out if an object is a SQLAlchemy mapped one?
[code]
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sqlalchemy
import sqlalchemy.ext.declarative
Base = sqlalchemy.ext.declarative.declarative_base()
class Model(Base):
__tablename__ = 'Table'
_oid = sqlalchemy.Column('oid', sqlalchemy.Integer,
primary_key=True)
model = Model()
# of course this is False
print ( Base == sqlalchemy.ext.declarative.declarative_base() )
# this can not work even
print( isinstance( model, sqlalchemy.ext.declarative.declarative_base()
) )
# but 'Base' is unknown at this point
# I need a generalized way to find out if a given instance is mapped
# by SQLAlchemy
[/code]
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.