[pybsddb] bsddb.db.DBNoSuchFileError on DBEnv.open

lasizoillo lasizoillo at gmail.com
Mon Aug 30 02:59:09 CEST 2010


2010/8/29 solsTiCe d'Hiver <solstice.dhiver at gmail.com>:
> Le dimanche 29 août 2010 à 19:37 +0200, lasizoillo a écrit :
>> Berkeley DB is hard to learn. I have been a lot of issues (at start
>> mostly). But all I remember was my fault ;-)
>>
> I have already used Berkeley DB API in C, some time ago. Although C in
> not very forgiving, I manage to do it with the very good documentation.
>
> But now I find almost harder to do it in python, with the incorrect doc
> or the code not working as I expect.
>
> explain to me why a simple code like:
> #include <db.h>
> #include <stdlib.h>
>
> int main(void) {
>        DB_ENV *env;
>        db_env_create(&env, 0);
>        env->open(env, ".db4", DB_INIT_MPOOL|DB_CREATE, 0);
>        env->close(env, 0);
>        return EXIT_SUCCESS;
> }
>
> works as expected.
> I have 3 files __db.001  __db.002  __db.003 that are created in .db4
> after I run the executable made with
> gcc -ldb -o testdb testdb.c
>
> how and why a simple thing as this does not work in python :-(
>

# #include <db.h>
from bsddb3 import db

if __name__ == '__main__':
    # DB_ENV *env;
    # db_env_create(&env, 0);
    env = db.DBEnv() #flags=0 is implicit
    # env->open(env, ".db4", DB_INIT_MPOOL|DB_CREATE, 0); # default
mode is implicit too
    env.open('.db4', db.DB_INIT_MPOOL | db.DB_CREATE)
    env.close()


The code is a direct translation of yours in c. Bindings are very
close to c api, but with some pythonic addons.

I'll be out of line for a week. Sorry if I can't reply more doubts.

Regards,

Javi


More information about the pybsddb mailing list