On this page
  1. dbm.open
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

dbm.open

Up: dbm | Next: dbm.whichdb
Rel: dbm.whichdb
Ref: docs.python.org — dbm.open
Tags: #public #python3 #stdlib #dbm


Import

import dbm
from dbm import open

Signature & Overview

dbm.open(file, flag='r', mode=438)

Open or create database at path given by file.

Usage

import dbm
from pathlib import Path
import tempfile

with tempfile.TemporaryDirectory() as tmp:
    path = str(Path(tmp) / "kv")
    with dbm.open(path, "c") as db:
        db["k"] = "v"
        assert db["k"] == b"v"

Gotchas

REPL Inspect

from dbm import open
help(open)

Linked from

Related notes