814
814
general such as using gdbm with pickle/shelve.
817
If my program crashes with a bsddb (or anydbm) database open, it gets corrupted. How come?
818
------------------------------------------------------------------------------------------
820
.. XXX move this FAQ entry elsewhere?
824
The bsddb module is now available as a standalone package `pybsddb
825
<http://www.jcea.es/programacion/pybsddb.htm>`_.
827
Databases opened for write access with the bsddb module (and often by the anydbm
828
module, since it will preferentially use bsddb) must explicitly be closed using
829
the ``.close()`` method of the database. The underlying library caches database
830
contents which need to be converted to on-disk form and written.
832
If you have initialized a new bsddb database but not written anything to it
833
before the program crashes, you will often wind up with a zero-length file and
834
encounter an exception the next time the file is opened.
837
I tried to open Berkeley DB file, but bsddb produces bsddb.error: (22, 'Invalid argument'). Help! How can I restore my data?
838
----------------------------------------------------------------------------------------------------------------------------
840
.. XXX move this FAQ entry elsewhere?
844
The bsddb module is now available as a standalone package `pybsddb
845
<http://www.jcea.es/programacion/pybsddb.htm>`_.
847
Don't panic! Your data is probably intact. The most frequent cause for the error
848
is that you tried to open an earlier Berkeley DB file with a later version of
849
the Berkeley DB library.
851
Many Linux systems now have all three versions of Berkeley DB available. If you
852
are migrating from version 1 to a newer version use db_dump185 to dump a plain
853
text version of the database. If you are migrating from version 2 to version 3
854
use db2_dump to create a plain text version of the database. In either case,
855
use db_load to create a new native database for the latest version installed on
856
your computer. If you have version 3 of Berkeley DB installed, you should be
857
able to use db2_load to create a native version 2 database.
859
You should move away from Berkeley DB version 1 files because the hash file code
860
contains known bugs that can corrupt your data.
863
817
Mathematics and Numerics
864
818
========================