Skip to content
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

How to re-open existing database? #19

Closed
ghost opened this issue Oct 7, 2019 · 2 comments
Closed

How to re-open existing database? #19

ghost opened this issue Oct 7, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Oct 7, 2019

Creating the database works fine using the example given at https://sophy.readthedocs.io/en/latest/api.html#Database , and it's stored to disk. And i can read values to and from it, at that moment.

But, when using get_database only, commenting out the add_database line, wanting to just reopen the stored existing database afterwards without overwriting it with a new (and then empty) one, i get this:

kv_db = env.get_database('kv') File "sophy.pyx", line 251, in sophy.Sophia.get_database KeyError: 'kv'

Is there something i'm doing incorrectly or have misunderstood?

My 'env' folder looks like this:

test/kv
test/kv/00000000000000000001.db
test/kv/scheme

Any help or tips are appreciated.

@coleifer
Copy link
Owner

coleifer commented Oct 7, 2019

The database schema configuration is not stored in the database, so you have to add the database schema / configure it every time you open the environment. Kinda sucks, not sure if the sophia maintainer has any plans on changing that.

@coleifer coleifer closed this as completed Oct 7, 2019
@ghost
Copy link
Author

ghost commented Oct 7, 2019

@coleifer Ah ok. Though, unless there's something i've overlooked, it seems to me that add_database will then simply overwrite/replace the pre-existing database, with an empty one.

EDIT: I was mistaken. Not sure how i previously managed to destroy my databases. But add_database does indeed NOT do what i stated above, using the documentation example.

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

No branches or pull requests

1 participant