How to use the bsddb3.dbshelve.open function in bsddb3

To help you get started, we’ve selected a few bsddb3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RecursiveG / UniSkinServer / src / uss_database.py View on Github external
def __init__(self, database_path: str):
        self.db = dbshelve.open(database_path)
    def close(self):
github kanzure / nanoengineer / packaging / Pref_Mod / preferences.py View on Github external
def _reopen():
    _ensure_shelf_exists()
    global _shelf
    assert _shelf is None
    _shelf = shelve.open(_shelfname.encode("utf_8"))
    # don't bother to re-update our _cache! This would be too slow to do every time.
    return
github gentoo / portage / lib / portage / _emirrordist / Config.py View on Github external
if self.options.dry_run:
			open_flag = "r"
		else:
			open_flag = "c"

		if self.options.dry_run and not os.path.exists(db_file):
			db = {}
		else:
			try:
				db = shelve.open(db_file, flag=open_flag)
			except ImportError as e:
				# ImportError has different attributes for python2 vs. python3
				if (getattr(e, 'name', None) == 'bsddb' or
					getattr(e, 'message', None) == 'No module named bsddb'):
					from bsddb3 import dbshelve
					db = dbshelve.open(db_file, flags=open_flag)

		if self.options.dry_run:
			logging.warning("dry-run: %s db opened in readonly mode" % db_desc)
			if not isinstance(db, dict):
				volatile_db = dict((k, db[k]) for k in db)
				db.close()
				db = volatile_db
		else:
			self._open_files.append(db)

		return db