-
Notifications
You must be signed in to change notification settings - Fork 29
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
ConfigurationError: montydb has been config to use BSON and cannot be changed in current session. #79
Comments
Hi @rkingsbury , sorry for my late reply 💦 I didn't do the test, but I believe it's possible to operate multiple instances of But the The thing is, MongoDB uses But for minimum dependency, it doesn't make much sense to add So the choice I made at that time, was to vendoring a small part of the Now back to the
Can you confirm this?
Specifically, the first time you initialize a
I think, if both databases were created with same Please let me know if anything is unclear or incorrect, this issue is on my radar now. 😊 |
Thank you for clarifying @davidlatwe ! The error message makes a little more sense to me now. In my case,
But if I continue in the above session and create clients using flatfile storage, I don't get this error:
|
Hi @davidlatwe , any thoughts about how to fix or work around this? For additional context, I'm trying to use |
Hey @rkingsbury , sorry again for another late reply, got flooded by works. 😅 And thanks for pinning me! The from montydb import MontyClient, set_storage
set_storage(
repository=":memory:",
storage="memory",
use_bson=True,
)
mc1 = MontyClient(":memory:")
mc2 = MontyClient(":memory:") It's not obvious, but the README did mention this, just not using Also noted that in memory storage, all clients are sourcing same storage instance. Here's the full code that I just tested, also checking that from montydb import MontyClient, set_storage
use_bson = True
set_storage(
repository=":memory:",
storage="memory",
use_bson=use_bson,
)
mc1 = MontyClient(":memory:")
mc2 = MontyClient(":memory:")
# Proving that two clients are using same memory storage
bar1 = mc1.get_database("foo").get_collection("bar")
bar2 = mc2.get_database("foo").get_collection("bar")
bar1.insert_one({"test": "doc"})
assert bar2.find_one({"test": "doc"}) == bar1.find_one({"test": "doc"})
# Check which bson module was used.
doc = bar1.find_one({"test": "doc"})
if use_bson:
assert type(doc["_id"]).__module__ == "bson.objectid"
else:
assert type(doc["_id"]).__module__ == "montydb.types.objectid" Hope this helps! |
Thanks for clarifying @davidlatwe ! So basically there can only be one |
It shouldn't be difficult to change that. Right now every instance of in-memory To change that, we will need to extend in-memory URL from Also needs to be thread-safe. See if I can implement that and make a new release by the end of this weekend. |
Hey @rkingsbury Got delayed, but the in-memory engine can now have independent repos. Please try it out. See |
Thanks so much for adding this @davidlatwe ! It works great. I used the following code to test.
If understanding correctly from reading your PR, I just need to make sure the repo name starts with I'm still slightly confused about where to use Anyway, thanks again for addressing! I'll go ahead and close. |
I am trying to use two instances of
MontyClient
simultaneously - one in memory and another on disk. Is this possible? Right now I am recieving the following error, which I am having trouble understanding.In the README I see
By "repository creation" do you mean "on instantiation of `MontyClient"? Is there any way to set the storage on a per-instance basis so that I can move data between different repositories, and memory?
Thanks for any assistance!
The text was updated successfully, but these errors were encountered: