--
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit
How can I find out if an object is a SQLAlchemy mapped one? It means if
it is derived from sqlalchemy.ext.declarative.declarative_base(). Using
isinstance() doesn't work in my tests.
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To unsubscribe
On 2015-06-05 20:53 c.bu...@posteo.jp 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):
On 2015-06-05 20:53 c.bu...@posteo.jp wrote:
How can I find out if an object is a SQLAlchemy mapped one?
This work, but I am not sure if it is elegant. What do you think?
type(type(model)) == type(sqlalchemy.ext.declarative.declarative_base())
--
You received this message because you are
You should be able to handle this by inspecting the object.
http://docs.sqlalchemy.org/en/latest/core/inspection.html
It will raise `sqlalchemy.exc.NoInspectionAvailable` if you can't inspect.
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To
How can I find out (based on the given code) if an attribute is a
foreign key, a primary key or nothing of that?
insp = sqlalchemy.inspection.inspect(model)
attrs = insp.attrs
for attr in attrs:
print('{}={}'.format(attr.key, attr.value)
The SQLA-docu is still quite hard for