On Sep 10, 2014, at 5:11 PM, Anton anschat...@gmail.com wrote:
So I am trying to do the following:
class SimpleModel(object):
__table_args__ = {'extend_existing': True}
id = db.Column(db.Integer, primary_key=True)
class GroupEntityAttributes(SimpleModel, db.Model):
Hi Mike,
I have two models that I did not provide in the example: Entity and Group.
Every group can assign some customer attributes to an entity, this is
reflected in GroupEntityAttributes.
Let's say GroupEntityAttributes(group_id=1, entity_id=1, key=color,
value=red) would mean that Group 1
hi Anton -
if you can show me correct table designs, e.g. as simple CREATE TABLE
statements, that definitely do the thing you need, I can show you how to map to
it. So far it's not clear if you're looking for schema design via SQLAlchemy's
API.
- mike
On Sep 10, 2014, at 6:36 PM, Anton
Mike, the tables are already there, I am trying to create models mapped on
the tables so it is easier to work with.
Tables design looks like:
CREATE TABLE group (
id integer NOT NULL,
name character varying
);
CREATE TABLE entity (
id integer NOT NULL,
name character varying
);
I already have models for group, entity and group_entity. Now I am trying
to build a model that would represent an entity for a group with all the
custom attributes.
On Wednesday, September 10, 2014 5:06:36 PM UTC-7, Anton wrote:
Mike, the tables are already there, I am trying to create
OK, just three tables, then just three mapped classes, that's it. The rest of
the stuff you're trying to do has to be done using standard Python techniques;
classes that implement special __getitem__() / __setitem__(), etc. Here's a
start, does just the get side so far:
from sqlalchemy
Hi,
I need some help choosing the right pattern for the models I have. I have
the following tables:
Entity (INT id, VARCHAR name)
Group (INT id, VARCHAT name)
GroupEntityAttributes(INT entity_id, INT group_id, VARCHAR key, VARCHAR
name)
Entity and Group models are pretty straight forward. But