Re: [sqlalchemy] Union on relationship

2016-10-26 Thread Alfred Soeng
Hi Mike, Are you free to talk through the fb messenger about my issue if you are good to it? Best, Alfred On Tue, Oct 25, 2016 at 2:44 PM, mike bayer wrote: > In a case like this I don't know what the problem is without being able to > run an example. The

Re: [sqlalchemy] similar to OrderingList but order in code instead of via sql?

2016-10-26 Thread mike bayer
On 10/26/2016 05:50 PM, Paul Winkler wrote: So I currently have this: thingies = relationship( "Thingy", order_by="Thingy.sort_order", collection_class=ordering_list("sort_order"), ) But could maybe change it to: thingies = relationship(

[sqlalchemy] similar to OrderingList but order in code instead of via sql?

2016-10-26 Thread Paul Winkler
Hi all, I've been happily using OrderingList as a collection_class for some time. Recently discovered a slow query due to multiple JOINs where the order_by on the relationship ends up causing a table scan because the field in question is not indexed. One solution of course would be to add an

Re: [sqlalchemy] Union on relationship

2016-10-26 Thread mike bayer
On 10/26/2016 02:09 PM, Alfred Soeng wrote: First of all, thanks for your response. 1. That makes more sense. 2. I use a select first, because there are actually more than 2 types of circuits, so there should be more models to be mapped to T_circirt. There are some models don't have vendor

Re: [sqlalchemy] Union on relationship

2016-10-26 Thread Alfred Soeng
First of all, thanks for your response. 1. That makes more sense. 2. I use a select first, because there are actually more than 2 types of circuits, so there should be more models to be mapped to T_circirt. There are some models don't have vendor but need to be mapped to the consistent model

Re: [sqlalchemy] Union on relationship

2016-10-26 Thread mike bayer
On 10/26/2016 12:03 PM, Alfred Soeng wrote: q1 = session.query(c1.mapper._class).options(joinedload('vendor')).options(load_load('id')) q2 = session.query(c2.mapper._class).options(joinedload('vendor')).options(load_load('id')) q1.union(q2).all() So there's some things to happen here: 1.

Re: [sqlalchemy] sqlalchemy with airflow and Oracle

2016-10-26 Thread mike bayer
oh. then they are timing out your connections due to inactivity. Set the "pool_timeout" parameter to a number of seconds less than this timeout. On 10/26/2016 10:24 AM, Vincent B. wrote: Thanks for this answer. As you suggested i tried to connect, with success, to my database through

Re: [sqlalchemy] Union on relationship

2016-10-26 Thread Alfred Soeng
struct T_AssetTransitCircuit { 1. asset_id 2. vendor_id 3. vendor } struct T_AssetTransportCircuit { 1. asset_id 2. vendor_id 3. vendor } struct T_Vendor { 1: i32 id, 2: optional string name, 3: optional string sf_id, 4: optional string transit_as_id, 5: optional i64 created_by, 6:

[sqlalchemy] Re: Union on relationship

2016-10-26 Thread Alfred Soeng
struct T_AssetTransitCircuit { 1. asset_id 2. vendor_id 3. vendor } struct T_AssetTransportCircuit { 1. asset_id 2. vendor_id 3. vendor } struct T_Vendor { 1: i32 id, 2: optional string name, 3: optional string sf_id, 4: optional string transit_as_id, 5: optional i64 created_by, 6:

Re: [sqlalchemy] sqlalchemy with airflow and Oracle

2016-10-26 Thread Vincent B.
Thanks for this answer. As you suggested i tried to connect, with success, to my database through cx_oracle. ip = '[MyOracleServerIP]' port = 1521 service_name = '[MyServiceName]' dsn = cx_Oracle.makedsn(ip, port, service_name=service_name) db = cx_Oracle.connect('[login]', '[password]', dsn)

Re: [sqlalchemy] Map a struct to multiple models

2016-10-26 Thread Mike Bayer
On Oct 25, 2016 5:53 PM, "Alfred Soeng" wrote: > > 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 =

Re: [sqlalchemy] sqlalchemy with airflow and Oracle

2016-10-26 Thread Mike Bayer
This is connectivity issues, I have no idea what airflow is, however if you're dropping connections this would be something to email the cx_oracle list about . The error message looks like you're not able to establish a connection in the first place. You might want to create a plain cx_oracle

[sqlalchemy] sqlalchemy with airflow and Oracle

2016-10-26 Thread Vincent B.
Hi, I am using sqlalchemy 1.0.5, Airflow 1.7.1.3, Python 2.7 and Oracle 12. I'm pretty much stuck with the integration of a connexion to Oracle through sqlalchemy in an Airflow Airbnb script. Here is my log from Airflow/sqlalchemy. [2016-10-26 14:51:07,574] {base.py:719} INFO - COMMIT

Re: [sqlalchemy] Simple SQLAlchemy hiearchical inheritance model

2016-10-26 Thread mike bayer
On 10/25/2016 05:46 PM, Robert C wrote: I am modeling a simple hierarchical database structure. My model is designed as follows: | |classChatMessage(Base): __tablename__ ='chat_message' sender_id =Column(Integer,ForeignKey('user.id'),primary_key=True) receiver_id

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

2016-10-26 Thread mike bayer
On 10/25/2016 04:43 PM, Jonathan Lowery wrote: 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"

Re: [sqlalchemy] Union on relationship

2016-10-26 Thread mike bayer
In a case like this I don't know what the problem is without being able to run an example. The guidelines at http://stackoverflow.com/help/mcve would make this easiest. Can we see complete mappings / table information (only what's needed to reproduce the problem) as well as how you are

Re: [sqlalchemy] Simple SQLAlchemy hiearchical inheritance model

2016-10-26 Thread Simon King
On Tue, Oct 25, 2016 at 10:46 PM, Robert C wrote: > I am modeling a simple hierarchical database structure. My model is designed > as follows: > > class ChatMessage(Base): > __tablename__ = 'chat_message' > sender_id = Column(Integer,