feat: add example showing how to open an existing ObjectBox database#33
Open
ElizioMartins wants to merge 1 commit into
Open
feat: add example showing how to open an existing ObjectBox database#33ElizioMartins wants to merge 1 commit into
ElizioMartins wants to merge 1 commit into
Conversation
Adds a new example that demonstrates ObjectBox transparently opens an existing database when Store(directory=...) points to a directory that already contains a data.mdb file. No special API is required. The example covers a common question from users: how to open a database that was created by a previous run or by another ObjectBox SDK. Also updates example/README.md to list the new example. Closes objectbox#20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Issue #20 (open since May 2024) shows that many users don't realize ObjectBox opens an existing database transparently — there is no special "open" API. When
Store(directory=\"...\")is called and the directory already contains adata.mdbfile, ObjectBox simply opens it. This confused users who thought they needed a separate API call.Solution
Added a new minimal example (
example/open-existing-db/) that demonstrates this behavior in three clear steps:The example also mentions the cross-platform use case (reading a database created by another ObjectBox SDK), which was the underlying motivation in the issue thread.
Files changed
example/open-existing-db/main.py— new self-contained exampleexample/README.md— added the new example to the list with description and sample outputCloses #20