From 11e299558da97c5d462253a8459cb67d3d0d8791 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Wed, 16 Feb 2022 17:11:42 -0500 Subject: [PATCH] database: fix insert_batch() If a namespace does not exist insert batch must create a new one rather than raise an exception. Signed-off-by: Eric Callahan --- moonraker/components/database.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/moonraker/components/database.py b/moonraker/components/database.py index 5d017a3..6e4ea8e 100644 --- a/moonraker/components/database.py +++ b/moonraker/components/database.py @@ -355,7 +355,10 @@ class MoonrakerDatabase: namespace: str, records: Dict[str, Any] ) -> None: - db = self._get_db(namespace) + if namespace not in self.namespaces: + self.namespaces[namespace] = self.lmdb_env.open_db( + namespace.encode()) + db = self.namespaces[namespace] with self.lmdb_env.begin(write=True, buffers=True, db=db) as txn: for key, val in records.items(): ret = txn.put(key.encode(), self._encode_value(val))