Skip to content

feat: add example showing how to open an existing ObjectBox database#33

Open
ElizioMartins wants to merge 1 commit into
objectbox:mainfrom
ElizioMartins:feat/open-existing-db-example
Open

feat: add example showing how to open an existing ObjectBox database#33
ElizioMartins wants to merge 1 commit into
objectbox:mainfrom
ElizioMartins:feat/open-existing-db-example

Conversation

@ElizioMartins
Copy link
Copy Markdown

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 a data.mdb file, 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:

# Step 1: create the database and write data
python main.py write

# Step 2: open the SAME directory — ObjectBox opens the existing DB automatically
python main.py read

# Step 3: reset to start fresh
python main.py reset

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 example
  • example/README.md — added the new example to the list with description and sample output

Closes #20


About the contributor: I'm a developer passionate about open source and always looking for opportunities to contribute and grow. If you're looking for collaborators or have open positions, feel free to reach out!

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Is there a way to open an existed data.mdb ?

1 participant