[sqlalchemy] How to combine class hierarchy and foreign keys

2019-03-28 Thread Huub van Thienen
I am working on a simple note taking application. There are Items which are just short pieces of text with a creation date. And there are Connections that link two Items together. The twist is that Connections are themselves Items, so, they have a text and creation date and can be connected

Re: [sqlalchemy] user-defined simple fields in a multi-tenant flask app with ORM

2019-03-28 Thread Ibrahima Gaye
Hi Jonathan, i would do it like this: - add in your global model tables named attributs, attributs_value and values, - any table (let's call it XTable) that will eventually has need extra column per client will be linked to attributs_value via a table XTable_Attributs (For maximum flexibility).

Re: [sqlalchemy] Re: Using operators with multiple InstrumentedAttribute instances

2019-03-28 Thread Jonathan Vanasco
On Thursday, March 28, 2019 at 6:27:52 PM UTC-4, Mike Bayer wrote: > > > is this some standard thing you're both doing? I didn't see anything > about joins or query analyzing.you often have answers for > questions where I don't understand what theyre asking! > Well his question and the

Re: [sqlalchemy] Re: Using operators with multiple InstrumentedAttribute instances

2019-03-28 Thread Mike Bayer
On Thu, Mar 28, 2019 at 5:33 PM Jonathan Vanasco wrote: > > I gave up on attempts to do something similar a while back, because it became > to problematic to examine all the SqlAlchemy objects – and the existing query > – in an effort to construct the joins and query correctly. > > I would up

Re: [sqlalchemy] Using operators with multiple InstrumentedAttribute instances

2019-03-28 Thread Mike Bayer
On Thu, Mar 28, 2019 at 4:43 PM Ian Miller wrote: > > Hello all, > > I am in the process of trying to create a dynamic expression query engine in > an application I'm working on. > > So there is a formula that gets defined like so: > > formula = '"metric:123" + "metric:456" + "metric:789"' > >

[sqlalchemy] Re: Using operators with multiple InstrumentedAttribute instances

2019-03-28 Thread Jonathan Vanasco
I gave up on attempts to do something similar a while back, because it became to problematic to examine all the SqlAlchemy objects – and the existing query – in an effort to construct the joins and query correctly. I would up using a two-phase approach. phase 1 analyzes the 'requested metrics'

[sqlalchemy] Using operators with multiple InstrumentedAttribute instances

2019-03-28 Thread Ian Miller
Hello all, I am in the process of trying to create a dynamic expression query engine in an application I'm working on. So there is a formula that gets defined like so: formula = '"metric:123" + "metric:456" + "metric:789"' Each metric maps to a column in the database tables - long story

Re: [sqlalchemy] user-defined simple fields in a multi-tenant flask app with ORM

2019-03-28 Thread Jonathan Vanasco
On Thursday, March 28, 2019 at 9:19:51 AM UTC-4, Mike Bayer wrote: > > > > Simpler solutions would be just using hstore or JSON types, but I would > be loosing the goodies of SQLAlchemy / Postgres schemas and consistency. > > this is totally how I'd want to do it unless your clients are given

Re: [sqlalchemy] user-defined simple fields in a multi-tenant flask app with ORM

2019-03-28 Thread Mike Bayer
On Thu, Mar 28, 2019 at 8:27 AM Xavier Bustamante Talavera wrote: > > Hello, > > Thanks in advance for the help. > > I am using the ORM with SQLAlchemy in a flask app that is multi-tenant > (multi-client): I have several running Flask apps, one per client. Each flask > app connects to a

[sqlalchemy] user-defined simple fields in a multi-tenant flask app with ORM

2019-03-28 Thread Xavier Bustamante Talavera
Hello, Thanks in advance for the help. I am using the ORM with SQLAlchemy in a flask app that is multi-tenant (multi-client): I have several running Flask apps, one per client. Each flask app connects to a different Postgres schema. I use one declarative base for all clients, as they share