On this page
dbm.whichdb
Prev: dbm.open | Up: dbm
Rel: dbm.open
Ref: docs.python.org — dbm.whichdb
Tags: #public #python3 #stdlib #dbm
Import
import dbm
from dbm import whichdb
Signature & Overview
dbm.whichdb(filename)
Guess which db package to use to open a db file.
Usage
import dbm
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as tmp:
path = str(Path(tmp) / "store")
with dbm.open(path, "c") as db:
db["a"] = "1"
assert dbm.whichdb(path) is not None
Gotchas
- Returns
Noneif missing,""if unrecognized, or the backend module name (e.g.,"dbm.ndbm","dbm.gnu","dbm.sqlite3").
REPL Inspect
from dbm import whichdb
help(whichdb)
Linked from
Related notes
- tuts/python3/stdlib_module/dbm/open Linked here; links to this page; shared tags: #dbm, #stdlib
- tuts/python3/stdlib_module/dbm Linked here; links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib
- tuts/c/stdlib/ctype shared tags: #stdlib
- tuts/c/stdlib/ctype/isalpha shared tags: #stdlib
- tuts/c/stdlib/ctype/isdigit shared tags: #stdlib
- tuts/c/stdlib/ctype/isspace shared tags: #stdlib