@@ -87,93 +87,6 @@ then prints out the contents of the database::
8787The individual submodules are described in the following sections.
8888
8989
90- :mod: `dbm.bsd ` --- DBM-style interface to the BSD database library
91- ------------------------------------------------------------------
92-
93- .. module :: dbm.bsd
94- :synopsis: DBM-style interface to the BSD database library.
95- ..
sectionauthor ::
Fred L. Drake, Jr. <[email protected] > 96-
97- .. index :: module: bsddb
98-
99- The :mod: `dbm.bsd ` module provides a function to open databases using the BSD
100- ``db `` library. This module mirrors the interface of the other Python database
101- modules that provide access to DBM-style databases. The :mod: `bsddb ` module is
102- required to use :mod: `dbm.bsd `.
103-
104- .. exception :: error
105-
106- Exception raised on database errors other than :exc: `KeyError `. It is a synonym
107- for :exc: `bsddb.error `.
108-
109-
110- .. function :: open(path[, flag[, mode]])
111-
112- Open a ``db `` database and return the database object. The *path * argument is
113- the name of the database file.
114-
115- The *flag * argument can be:
116-
117- +---------+-------------------------------------------+
118- | Value | Meaning |
119- +=========+===========================================+
120- | ``'r' `` | Open existing database for reading only |
121- | | (default) |
122- +---------+-------------------------------------------+
123- | ``'w' `` | Open existing database for reading and |
124- | | writing |
125- +---------+-------------------------------------------+
126- | ``'c' `` | Open database for reading and writing, |
127- | | creating it if it doesn't exist |
128- +---------+-------------------------------------------+
129- | ``'n' `` | Always create a new, empty database, open |
130- | | for reading and writing |
131- +---------+-------------------------------------------+
132-
133- For platforms on which the BSD ``db `` library supports locking, an ``'l' ``
134- can be appended to indicate that locking should be used.
135-
136- The optional *mode * parameter is used to indicate the Unix permission bits that
137- should be set if a new database must be created; this will be masked by the
138- current umask value for the process.
139-
140- The database objects returned by :func: `open ` provide the methods common to all
141- the DBM-style databases and mapping objects. The following methods are
142- available in addition to the standard methods:
143-
144- .. method :: dbhash.first()
145-
146- It's possible to loop over every key/value pair in the database using this
147- method and the :meth: `next ` method. The traversal is ordered by the databases
148- internal hash values, and won't be sorted by the key values. This method
149- returns the starting key.
150-
151- .. method :: dbhash.last()
152-
153- Return the last key/value pair in a database traversal. This may be used to
154- begin a reverse-order traversal; see :meth: `previous `.
155-
156- .. method :: dbhash.next()
157-
158- Returns the key next key/value pair in a database traversal. The following code
159- prints every key in the database ``db ``, without having to create a list in
160- memory that contains them all::
161-
162- print(db.first())
163- for i in range(1, len(db)):
164- print(db.next())
165-
166- .. method :: dbhash.previous()
167-
168- Returns the previous key/value pair in a forward-traversal of the database. In
169- conjunction with :meth: `last `, this may be used to implement a reverse-order
170- traversal.
171-
172- .. method :: dbhash.sync()
173-
174- This method forces any unwritten data to be written to the disk.
175-
176-
17790:mod: `dbm.gnu ` --- GNU's reinterpretation of dbm
17891------------------------------------------------
17992
0 commit comments