Giter Site home page Giter Site logo

nim-lmdb's Introduction

Nim LMDB

badge tags License CircleCI

Nim wrapper for the Symas LMDB library

"…​with only 32KB of object code, LMDB may seem tiny. But it’s the right 32KB." - from the LMDB home page.

More documentation: upstream docs - wikipedia page - exploring LMDB

Features

  • Lightweight and ultra fast

  • nim doc documentation

  • Basic functional tests and benchmarks

  • Tested on Linux

Usage

# Development library:
nimble install lmdb

# Runtime dependency:
sudo apt-get install liblmdb0
import lmdb

# create dbenv, transaction and a dbi
let dbenv = newLMDBEnv("./testdb")
let txn = dbenv.newTxn()
let dbi = txn.dbiOpen(nil, 0)

txn.put(dbi, "foo", "value")
let g = txn.get(dbi, "foo")
txn.del(dbi, "foo", "value")

# commit or abort transaction
txn.commit() # or txn.abort()

# close dbi and env
dbenv.close(dbi)
dbenv.envClose()

Also see tests/functional.nim for more examples.

Contributing

Testing and PRs are welcome.

nim-lmdb's People

Contributors

federicoceratto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nim-lmdb's Issues

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

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.