[sqlalchemy] Re: Help- Building Join in Graph Structure.

2018-02-07 Thread madhusudan600019
Thank you very much, Jonathan Vanasco. I have not considered backrefs, I will take a look. but, Is there a way to not use backref but directly used these edges (edge_1 and edge_2) to get node_1 and node_3? On Wednesday, February 7, 2018 at 1:42:26 PM UTC-6, Jonathan Vanasco wrote: > > actually

[sqlalchemy] Re: Help- Building Join in Graph Structure.

2018-02-07 Thread Jonathan Vanasco
actually, you'd be constraining the join against the edge elements since the base is a node. (edge is the more common name for your usage/link) if you're searching for node2, then you'd constrain the query by joining the edge items like this: result = session.query(node_2)\ .join(edge_1, node

[sqlalchemy] Re: Help- Building Join in Graph Structure.

2018-02-07 Thread madhusudan600019
What is the efficient way to generalize such joins, If I am parsing a graph and get the joins dynamically? On Wednesday, February 7, 2018 at 1:09:42 PM UTC-6, madhusud...@gmail.com wrote: > > Thank you, Could you elaborate on how would I "constrain the selection > with joins to node1 and node3

[sqlalchemy] Re: Help- Building Join in Graph Structure.

2018-02-07 Thread madhusudan600019
Thank you, Could you elaborate on how would I "constrain the selection with joins to node1 and node3"? I am still not clear on that part. On Wednesday, February 7, 2018 at 12:57:59 PM UTC-6, Jonathan Vanasco wrote: > > I do a lot with graphs in SqlAlchemy, and I think you'd have a easier time >

[sqlalchemy] Re: Help- Building Join in Graph Structure.

2018-02-07 Thread Jonathan Vanasco
I do a lot with graphs in SqlAlchemy, and I think you'd have a easier time writing these queries if you flipped your search so that you're querying a single identified object. For example, on use-case-1, you can query for the "Usage", and join the nodes. > result = session.query(Usage)\ > .joi

[sqlalchemy] Help- Building Join in Graph Structure.

2018-02-07 Thread madhusudan600019
Hi Mike, I am creating a graph structure using the ORM below and am able to do inserts. Base = declarative_base() class Link(Base): __tablename__ = 'base_link' _constraints = ['first_id', 'second_id'] __table_args__ = (UniqueConstraint(*_constraints, name = 'link_constraint'), {"schema":"my_

Re: [sqlalchemy] Help resolving Could not determine join condition between parent/child tables on relationship error message

2018-02-07 Thread Mike Bayer
On Wed, Feb 7, 2018 at 6:01 AM, Jeremy Flowers wrote: > Hi > I've recently used sqlacodegen > > When I try and run against the generated code it get this message that I've > been unable to fix: > > Could not determine join condition between parent/child tables on > relationship Workgrp.usrmst - t

Re: [sqlalchemy] Events and bidirectionnal datas modification

2018-02-07 Thread Mike Bayer
On Wed, Feb 7, 2018 at 7:16 AM, tonthon wrote: > Hi, > > I'd like to setup bidirectionnal data synchornization between the lastname > attribute of two related models > > class User(Base): > __tablename__ = 'users' > id = Column(Integer, primary_key=True) > lastname = Column(String(50)) >

[sqlalchemy] running py.test

2018-02-07 Thread su-sa
Hallo everyone, I am trying to run all the pytest of sqlalchemy. But I always get the error - SQLAlchemy requires Mock as of version 0.8.2. I already have the mock library installed. Could somebody please help me to solve the problem. Thanks in advance, Greetings, S -- SQLAlchemy - The Pyt

[sqlalchemy] Re: Relationships - crash when class instantiation

2018-02-07 Thread Sven
Thank you Mike. I'll try that :-) I'll keep you informed. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a ful

Re: [sqlalchemy] Relationships - crash when class instantiation

2018-02-07 Thread Sven
Hello Gaston, In deed, there is no mistakes in my example. That was just here in order to illustrate my explanations. I tried to reproduce the problem, without success. If the problem is vicious, I could spend a huge amount of time trying to reproduce it. This is why I have thought It could b

Re: [sqlalchemy] Relationships - crash when class instantiation

2018-02-07 Thread Mike Bayer
On Feb 7, 2018 6:09 AM, "Sven" wrote: Hello everybody, Today, I have a strange problem regarding relationships. My project contains already several relationships and until now, I never had any problem with these. But now, when I try to add a new relationship between two classes, the entire prog

Re: [sqlalchemy] Relationships - crash when class instantiation

2018-02-07 Thread tonthon
Hi, There's nothing that could cause the problem you describe in the example you provide maybe the guilty lines where not included. The easier way to go should be to step by step reproduce your model structure until you face the problem you describe and then post an example code :  http://stackov

Re: [sqlalchemy] Help resolving Could not determine join condition between parent/child tables on relationship error message

2018-02-07 Thread tonthon
Hi, When SQALchemy can't guess the join condition to use for a relationship, you have to use the primaryjoin parameter : ursmst = relationship('Usrmst', primaryjoin="Workgrp.workgrp_owner==Usrmst.id") Hope this helps. Regards Gaston Le 07/02/2018 à 12:01, Jeremy Flowers a écrit : > Hi > I've

[sqlalchemy] Events and bidirectionnal datas modification

2018-02-07 Thread tonthon
Hi, I'd like to setup bidirectionnal data synchornization between the lastname attribute of two related models class User(Base):     __tablename__ = 'users'     id = Column(Integer, primary_key=True)     lastname = Column(String(50))     userdatas = relationship('UserDatas', primaryjoin='User.id=

[sqlalchemy] Relationships - crash when class instantiation

2018-02-07 Thread Sven
Hello everybody, Today, I have a strange problem regarding relationships. My project contains already several relationships and until now, I never had any problem with these. But now, when I try to add a new relationship between two classes, the entire program suddenly crashes without displayin

[sqlalchemy] Help resolving Could not determine join condition between parent/child tables on relationship error message

2018-02-07 Thread Jeremy Flowers
Hi I've recently used sqlacodegen When I try and run against the generated code it get this message that I've been unable to fix: Could not determine join condition between parent/child tables on relationship Workgrp.usrmst - there are multiple foreign key paths linking the tables. Specify th