[py-lmdb] Re: create_env() and open_env()

  • From: "Dinesh Vadhia" <dineshvadhia@xxxxxxxxxxx>
  • To: <py-lmdb@xxxxxxxxxxxxx>
  • Date: Fri, 23 May 2014 05:19:08 -0700

The lmdb api doc says:

"create_env(): This function allocates memory for a MDB_env structure. To release the allocated memory and discard the handle, call mdb_env_close(). Before the handle may be used, it must be opened using mdb_env_open()."

"env       An environment handle returned by mdb_env_create()"

The way I read this (and probably incorrectly!) is that create_env() creates an Env. It says, "allocates memory for a MDB_env structure" but it also sets aside storage using map_size (surely?).

Say, an lmdb db has been created with create_env(). Now, how to use it within a program or modules? Is create_env() called first to allocate memory and a handle and then open_env() to use it? If so, py-lmdb's lmdb.open(path, *kwargs) doesn't ask for the Env handle.

Just a bit confused!

From: "David Wilson" <dw@xxxxxxxx>
Sent: Wednesday, May 21, 2014 4:41 PM
To: <py-lmdb@xxxxxxxxxxxxx>
Subject: [py-lmdb] Re: create_env() and open_env()

Hey Dinesh,

Neither of these are functions from py-lmdb. There it is simply
"lmdb.open()", unless I'm somehow confused. :)


On Wed, May 21, 2014 at 03:44:50PM -0700, Dinesh Vadhia wrote:
Maybe I don't understand the difference but:

a. create_env() creates the initial environment including setting the path to
the env, the map_size etc.

b. open_env(path) opens an env

In practice, open_env() has to be passed all the parameters that were used for

It seems as if create_env() and open_env() are identical.

Is this right?

Other related posts: