object-relational-model

connect SQLAlchemy ORM with the objects from sql core expression?

社会主义新天地 提交于 2020-01-23 01:48:29
问题 I have to use SQLalchemy Core expression to fetch objects because ORM can't do "update and returning". (the update in ORM doesn't has returning ) from sqlalchemy import update class User(ORMBase): ... # pure sql expression, the object returned is not ORM object. # the object is a RowProxy. object = update(User) \ .values({'name': 'Wayne'}) \ .where(User.id == subquery.as_scalar()) \ .returning() \ .fetchone() When db_session.add(object) it report UnmappedInstanceError: Class 'sqlalchemy

connect SQLAlchemy ORM with the objects from sql core expression?

喜欢而已 提交于 2020-01-23 01:48:05
问题 I have to use SQLalchemy Core expression to fetch objects because ORM can't do "update and returning". (the update in ORM doesn't has returning ) from sqlalchemy import update class User(ORMBase): ... # pure sql expression, the object returned is not ORM object. # the object is a RowProxy. object = update(User) \ .values({'name': 'Wayne'}) \ .where(User.id == subquery.as_scalar()) \ .returning() \ .fetchone() When db_session.add(object) it report UnmappedInstanceError: Class 'sqlalchemy

Choosing between Symfony's Doctrine ORM files Model.class.php and ModelTable.class.php

此生再无相见时 提交于 2019-12-13 04:46:38
问题 when doctrine builds model files for a table, it generates three files, essentially BaseModel.class.php , Model.class.php and ModelTable.class.php . Common knowledge requires that any modifications be done to Model.class.php or ModelTable.class.php vs BaseModel.class.php . But when do you choose between either Model.class.php vs ModelTable.class.php . From what I gather is that Model.class.php is for a single instance and ModelTable.class.php is for multiple instances. Can anyone shed any

multiple/split class associations in sqlalchemy

爱⌒轻易说出口 提交于 2019-12-10 13:58:46
问题 I have the following objects and relations defined. This is actually quite a simple case, and I am providing all those fields just to show why I believe inhalation and injection anesthesia should be defined by two different classes. class InhalationAnesthesia(Base): __tablename__ = "inhalation_anesthesias" id = Column(Integer, primary_key=True) anesthetic = Column(String) concentration = Column(Float) concentration_unit = Column(String) duration = Column(Float) duration_unit = Column(String)

Is it a bad idea to use a database's primary key as business object identifier?

心不动则不痛 提交于 2019-12-07 07:53:12
问题 I wonder, is it bad or good idea to use auto increment primary key as business entity identifier such as Partner Id or Account Number ? Also, what pitfalls I can face if I'll choose that approach? 回答1: I don't think everyone shares the same opinion, but I do think it is bad practice. Passing ID's to the user as the 'key' is bad in my opinion, for a number of reasons: ID's aren't natural to users. They are not talking about project '1474623', they are talking about project 'ABC'. They aren't

Is it a bad idea to use a database's primary key as business object identifier?

家住魔仙堡 提交于 2019-12-05 08:56:48
I wonder, is it bad or good idea to use auto increment primary key as business entity identifier such as Partner Id or Account Number ? Also, what pitfalls I can face if I'll choose that approach? I don't think everyone shares the same opinion, but I do think it is bad practice. Passing ID's to the user as the 'key' is bad in my opinion, for a number of reasons: ID's aren't natural to users. They are not talking about project '1474623', they are talking about project 'ABC'. They aren't talking about person '363528', they are talking about 'Patrick Hofman'; ID's are fragile. You can't really

connect SQLAlchemy ORM with the objects from sql core expression?

做~自己de王妃 提交于 2019-12-04 14:01:45
I have to use SQLalchemy Core expression to fetch objects because ORM can't do "update and returning". (the update in ORM doesn't has returning ) from sqlalchemy import update class User(ORMBase): ... # pure sql expression, the object returned is not ORM object. # the object is a RowProxy. object = update(User) \ .values({'name': 'Wayne'}) \ .where(User.id == subquery.as_scalar()) \ .returning() \ .fetchone() When db_session.add(object) it report UnmappedInstanceError: Class 'sqlalchemy.engine.result.RowProxy' is not mapped . How do I put that RowProxy object from sql expression into identity

How can I define a type in oracle11g that references a collection of that type?

隐身守侯 提交于 2019-12-01 21:14:04
问题 I want to do something like this create type Item as object ( id number, subitems table of ref Item ) but oracle throws an exception when I try to do it. Is this possible, and if yes then how? 回答1: Oracle will not compile your definition because the type Item hasn't been compiled yet. Why dont you give this a try: Compile this: CREATE OR REPLACE TYPE Item; CREATE OR REPLACE TYPE items_table IS TABLE OF REF item; and then try: CREATE OR REPLACE TYPE item AS OBJECT ( id number, subitems items

How can I define a type in oracle11g that references a collection of that type?

牧云@^-^@ 提交于 2019-12-01 20:02:56
I want to do something like this create type Item as object ( id number, subitems table of ref Item ) but oracle throws an exception when I try to do it. Is this possible, and if yes then how? Oracle will not compile your definition because the type Item hasn't been compiled yet. Why dont you give this a try: Compile this: CREATE OR REPLACE TYPE Item; CREATE OR REPLACE TYPE items_table IS TABLE OF REF item; and then try: CREATE OR REPLACE TYPE item AS OBJECT ( id number, subitems items_table ) That would be nice wouldn't it! You could try this: create type item_ids_t is table of number; create