-
-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Emmett ORM separately from the App (in a Notebook) #309
Comments
Hi @PierreDelarroqua, actually the plan is to have ORM separated into a dedicated package for 3.x release, which has no ETA (yet). In the meantime, you have two ways to do what you ask: from emmett import App
from emmett.orm import Database
db = Database(App(__name__)) b) hack your database instance using a fake application object, eg from collections import defaultdict
from emmett import sdict
from emmett.orm import Database
app = sdict(
config=sdict(db=sdict()),
log=defaultdict(lambda: lambda *a, **b: None),
send_signal=lambda *a, **b: None
)
db = Database(app) In both cases, you just need to explicitly open connections when running queries, eg: with db.connection():
Model.where(...) |
@gi0baro thank you very much, that's great ! We'll use this right away ! |
@gi0baro sorry to bother you again. In both cases, it doesn't work for us: Error Case A:
Error Case B:
Any idea how to make it work ? Thank you, |
@PierreDelarroqua woah, the first traceback is quite a mistery to me. I'm definitely not sure how is it possible Regarding the 2nd one, probably adding an attribute for the app = sdict(
config=sdict(db=sdict()),
log=defaultdict(lambda: lambda *a, **b: None),
send_signal=lambda *a, **b: None,
root_path=os.getcwd()
) |
Hey @gi0baro ,
I wanted to know use Emmett ORM separately from the App.
Ideally, I would use a Notebook where I would declare the DB and the Models, attach the Models to the DB, and test different queries.
Is it possible ?
Thank you!
Pierre
The text was updated successfully, but these errors were encountered: