| 
									
										
										
										
											1998-08-10 19:42:37 +00:00
										 |  |  | \section{\module{dbm} --- | 
					
						
							| 
									
										
										
										
											1999-02-20 00:14:17 +00:00
										 |  |  |          Simple ``database'' interface} | 
					
						
							| 
									
										
										
										
											1998-07-23 17:59:49 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1999-02-20 00:14:17 +00:00
										 |  |  | \declaremodule{builtin}{dbm} | 
					
						
							| 
									
										
										
										
											1999-03-02 17:03:42 +00:00
										 |  |  |   \platform{Unix} | 
					
						
							| 
									
										
										
										
											1998-07-23 17:59:49 +00:00
										 |  |  | \modulesynopsis{The standard ``database'' interface, based on ndbm.} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-01-02 01:22:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1999-02-20 00:14:17 +00:00
										 |  |  | The \module{dbm} module provides an interface to the \UNIX{} | 
					
						
							| 
									
										
										
										
											1995-07-07 22:55:57 +00:00
										 |  |  | \code{(n)dbm} library.  Dbm objects behave like mappings | 
					
						
							|  |  |  | (dictionaries), except that keys and values are always strings. | 
					
						
							|  |  |  | Printing a dbm object doesn't print the keys and values, and the | 
					
						
							| 
									
										
										
										
											1999-03-02 16:37:17 +00:00
										 |  |  | \method{items()} and \method{values()} methods are not supported. | 
					
						
							| 
									
										
										
										
											1995-07-07 22:55:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1999-02-20 00:14:17 +00:00
										 |  |  | See also the \refmodule{gdbm}\refbimodindex{gdbm} module, which | 
					
						
							|  |  |  | provides a similar interface using the GNU GDBM library. | 
					
						
							| 
									
										
										
										
											1994-01-02 01:22:07 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | The module defines the following constant and functions: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | \begin{excdesc}{error} | 
					
						
							| 
									
										
										
										
											1999-02-20 00:14:17 +00:00
										 |  |  | Raised on dbm-specific errors, such as I/O errors. | 
					
						
							|  |  |  | \exception{KeyError} is raised for general mapping errors like | 
					
						
							|  |  |  | specifying an incorrect key. | 
					
						
							| 
									
										
										
										
											1994-01-02 01:22:07 +00:00
										 |  |  | \end{excdesc} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-17 06:33:25 +00:00
										 |  |  | \begin{funcdesc}{open}{filename, \optional{flag, \optional{mode}}} | 
					
						
							| 
									
										
										
										
											1995-07-07 22:55:57 +00:00
										 |  |  | Open a dbm database and return a dbm object.  The \var{filename} | 
					
						
							|  |  |  | argument is the name of the database file (without the \file{.dir} or | 
					
						
							|  |  |  | \file{.pag} extensions). | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The optional \var{flag} argument can be | 
					
						
							|  |  |  | \code{'r'} (to open an existing database for reading only --- default), | 
					
						
							|  |  |  | \code{'w'} (to open an existing database for reading and writing), | 
					
						
							|  |  |  | \code{'c'} (which creates the database if it doesn't exist), or | 
					
						
							|  |  |  | \code{'n'} (which always creates a new empty database). | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The optional \var{mode} argument is the \UNIX{} mode of the file, used | 
					
						
							|  |  |  | only when the database has to be created.  It defaults to octal | 
					
						
							|  |  |  | \code{0666}. | 
					
						
							| 
									
										
										
										
											1994-01-02 01:22:07 +00:00
										 |  |  | \end{funcdesc} | 
					
						
							| 
									
										
										
										
											1999-04-05 22:18:12 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | \begin{seealso} | 
					
						
							|  |  |  |   \seemodule{anydbm}{Generic interface to \code{dbm}-style databases.} | 
					
						
							|  |  |  |   \seemodule{whichdb}{Utility module used to determine the type of an | 
					
						
							|  |  |  |                       existing database.} | 
					
						
							|  |  |  | \end{seealso} |