Comments (8)
Thank you for answer. I want to make multitenant app with schema per tenant and need to execute queries with specific schema
from edgy.
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.
I'm afraid that I don't have enough experience and skills to do this, but I will try
from edgy.
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.
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.
- 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.
- Shared database, different Schemas - The user's data is split by different schemas but live on the same database.
- 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.
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.
Give it a try. Add this idea also to the Discussion section of Edgy as an idea. This is a good one.
from edgy.
Closing here as this was moved to discussion #14
from edgy.
Related Issues (11)
- Create Custom manager HOT 2
- Generate Models from existing database HOT 18
- double initialization of metaclasses / fields contain references to old fields HOT 2
- ManyToMany's Related Manager is not provided on object HOT 4
- handle cached_properties properly
- pkcolumns do take wrong id infos HOT 1
- Reinitializing models with indexes
- Move to builtin hatch functionality+uv HOT 3
- Pin databasez version to <0.8 HOT 2
- Tests fail for databasez >= 0.9.0 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from edgy.