GithubHelp home page GithubHelp logo

Comments (8)

rorik302 avatar rorik302 commented on August 21, 2024 1

Thank you for answer. I want to make multitenant app with schema per tenant and need to execute queries with specific schema

from edgy.

rorik302 avatar rorik302 commented on August 21, 2024 1

I prefer second option "Shared database, multiple schemas".
Maybe queryset could be like User.with_db_schema(schema_name).query.all(), where with_db_schema function switching to required database schema?

from edgy.

rorik302 avatar rorik302 commented on August 21, 2024 1

I'm afraid that I don't have enough experience and skills to do this, but I will try

from edgy.

tarsil avatar tarsil commented on August 21, 2024

Hello. Why would you use sessions with Saffier or Edgy? So, both use an underlying tool that manages the database connections and the sessions like the ones used in SQL Alchemy ORM are managed internally. Now, Saffier and Edgy use SQLAlchemy Core. But if you really want that, then you can use the connection object used in both Saffier and Edgy.

Lets use the following example.

from edgy import Database, Registry

database = Database("postgresql+asyncpg://postgres:postgres@localhost:5432/my_db")
models = Registry(database=database)

...

The objects managing the connections are the database and registry. The registry holds your model information tables and the databases the connections. So switching would be updating both of them and keep using the ORM as normal.

Edgy and Saffier use the underlying technology (https://databasez.tarsild.io/) to manage the DB connections automatically for you.

The SQLAlchemy Session is used in SQLAlchemy ORM and not he Core. As mentioned in the documentation, Edgy and Saffier use the SQLAlchemy Core.

I hope this helps :)

from edgy.

tarsil avatar tarsil commented on August 21, 2024

I suspected that from the type of question. I did something similar when I was using Django as well. The thing is that depends of your approach. Multi tenancy you can have in 3 ways.

  1. Shared schemas - The data of all users are shared within the same schema and filtered by common IDs or whatever that is unique to the platform. This is not so great for GDPR.
  2. Shared database, different Schemas - The user's data is split by different schemas but live on the same database.
  3. Different databases - The user's data or any data live on different databases.

I hope I was able to answer your questions? Also, thank you for choosing Edgy :)

from edgy.

tarsil avatar tarsil commented on August 21, 2024

I actually like the idea but It would be better to see a possible PR with your idea there. Do you have the chance to create one? That would be a good addition 👍🏼

from edgy.

tarsil avatar tarsil commented on August 21, 2024

Give it a try. Add this idea also to the Discussion section of Edgy as an idea. This is a good one.

from edgy.

tarsil avatar tarsil commented on August 21, 2024

Closing here as this was moved to discussion #14

from edgy.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.