[sqlalchemy] ORM - decoupling sqlalchemy models from, and reintegrating back into, a framework/library

2016-10-25 Thread Jonathan Vanasco
The model for a given project exists within a Pyramid application, `foo_pyramid`. Other services in Celery and Twisted have been integrated against it with almost no trouble. The one bit of trouble is that some convenience methods on the ORM classes implemented for Pyramid are triggering a

[sqlalchemy] Map a struct to multiple models

2016-10-25 Thread Alfred Soeng
Hi, If I want to map a struct to 2 tables who have mostly the same info but different format, is that feasible? e.g struct T { 1. id 2. name} a_mapper = mapper(T, m1, properties={...}) b_mapper = mapper(T, m2, properties={...}) I tried to specify the b_mapper to non-primary one, but when I

[sqlalchemy] Simple SQLAlchemy hiearchical inheritance model

2016-10-25 Thread Robert C
I am modeling a simple hierarchical database structure. My model is designed as follows: class ChatMessage(Base): __tablename__ = 'chat_message' sender_id = Column(Integer, ForeignKey('user.id'), primary_key=True) receiver_id = Column(Integer, ForeignKey('user.id'), primary_key=True)

[sqlalchemy] Union on relationship

2016-10-25 Thread Alfred Soeng
When I union 2 queries, it seems combine the same relationship together and cause the alias problem In the code, it generated 2 queries like: q1: SELECT anon_1.id AS anon_1_id, anon_1.vendor_id AS anon_1_vendor_id, vendor_1.id AS vendor_1_id, vendor_1.name AS vendor_1_name, vendor_1.sf_id AS

[sqlalchemy] Oracle data type "TIMESTAMP WITH LOCAL TIME ZONE"

2016-10-25 Thread Jonathan Lowery
No support currently exists for this oracle datatype because of the way the Oracle dialect parses data types in sqlalchemy\dialects\oracle\base.py A column in a table I am attempting to reflect is of the type "TIMESTAMP WITH LOCAL TIME ZONE" A temporary monkey-patch fix I've got for now is as

[sqlalchemy] Re: JOIN result as dict

2016-10-25 Thread Joasia
q.all()._asdict() It does not work. It is a kind of a mental shortcut (sorry for that!). It is only possible in (like you said): for r in q.all(): r._as_dict() Thank you for your reply! I had hope that I don't have to do any casting or explicity query enumerate. W dniu czwartek, 20