Hi, thank you for the quick reply; I will check this solution. As for number of clients - clients are actually companies, so number can be maybe few dozens, or hundred - does this change anything?
Thanks in advance On Saturday, October 22, 2016 at 2:08:33 PM UTC+2, Nikola Radovanovic wrote: > > Hi all, > I have a question regarding what will be the best possible way to resolve > following scenario: > > 1. lets say I have table(s) in 'public' schema and multiple 'private' > schemes with same table layout > 2. each private schema is for separate customer, and public contains > some data everyone may access > 3. clients are dynamic category: i.e some might be added or removed > during runtime > > There are various relationships (one-to-one, one-to-many and many-to-many) > for tables/objects in: > > 1. same schema and > 2. private and public schemes (but not among privates) > > Basically, I created (virtual) base class for each 'private' object and > 'generator' class that can create Python class for specific client along > with proper relationships towards 'public' table(s) and 'private' tables > reside in same schema. Each class is within its own python file. There is > also a Base class (from declarative_base()) all objects in my model > inherits. When adding a client, I use *setattr* to add relationship > property to class > > So, I am wandering: > > 1. is this good way to go > 2. I have few classes inherits from db.Model (FLASK app) - will it be > good idea to switch them also to use same Base object > 3. since I don't know in advance number/names of the clients and there > are generated Python classes - how does this affects usage of metadata to > create tables. I noticed troubles with i.e. many-to-many when client from > public schema try to set backref; I got error about multiple definitions > in > ORM (like it tries to add same relationship multiple times) > > Thank You all in advance > -- 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 full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.