# pydoc > _dbm

---
type: CommandReference
command: _dbm
mode: pydoc
section: ""
source: pydoc3
---

## Quick Reference
- `_dbm.open(filename, flags, mode)` — Open a DBM database file and return a database object.

## Name
`_dbm` — Low-level interface to the DBM library (Berkeley DB).

## Synopsis
python
import _dbm
## Options
### Functions
- `open(filename, flags, mode)` — Return a database object.  
  - `filename` — The path to the database file.  
  - `flags` — How to open the file: `"r"` for reading, `"w"` for writing, etc.  
  - `mode` — If creating a new file, the mode bits (e.g., `os.O_RDWR`).

### Classes
- `error` — Exception raised for database errors. Subclass of `OSError`. Inherits attributes:
  - `errno` — POSIX exception code  
  - `filename` — exception filename  
  - `filename2` — second exception filename  
  - `strerror` — exception strerror  
  - `characters_written` (inherited from `OSError`)  
  - `__weakref__` — list of weak references to the object.

## Examples
python
import _dbm

# Open an existing database for reading
db = _dbm.open('mydb.db', 'r')

# Open for writing (creates if not exists)
db = _dbm.open('mydb.db', 'w', 0o644)

# Close the database
db.close()
## See Also
- [Python `_dbm` module documentation](https://docs.python.org/3.10/library/_dbm.html)
- [`dbm` module](https://docs.python.org/3.10/library/dbm.html) — higher-level interface