Skip to content
This repository has been archived by the owner on Aug 17, 2024. It is now read-only.

[Question] how to get (unknown) keys of named DB #2

Open
ITwrx opened this issue Oct 16, 2020 · 0 comments
Open

[Question] how to get (unknown) keys of named DB #2

ITwrx opened this issue Oct 16, 2020 · 0 comments

Comments

@ITwrx
Copy link

ITwrx commented Oct 16, 2020

Hi,
Thanks for the library. I'm thinking this will be a big speed-up for my applications, but i'm having trouble making use of it.
I'm not seeing a proc for getting all keys of a named DB, so i'm guessing i need to get the count of key/value pairs using:

let c = txn.cursorOpen(dbi)
let key_count = c.count()

then, get the keys with something like this:

while i <= count:
  if i == 1:
    key = c.get("", op = FIRST)
  else:
    key = c.get("", op = NEXT)

  echo key

the empty string are to be a wild attempt at stumbling upon the answer via error message, as i don't see an example with anything besides a hard coded string. Also, I don't understand why the cursor needs a key to be specified to move through keys (using FIRST and NEXT) anyways.

when i try to use count(), it says the DB is not compat. so, i try to add DUPSORT to the DB and it complains that my flags have changed. I try to delete and recreate the DB, but i can't find the syntax for adding more than one dbflag when creating a new DB. I'm thinking i need DUPSORT and CREATE.

I've been at this longer than i care to admit, so any help is appreciated.

Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant