aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2025-02-10 17:27:29 +0200
committerJan Tuomi <jan@jantuomi.fi>2025-02-10 17:27:29 +0200
commiteaa04ae170e57b1688bd10936a19fcb91f3409e0 (patch)
tree2955eaee53958f17bd0315f1a4c287347cee8a5a
parentaed6b0a1c213e8e8b7f1fc4ee16681d326fd3a4d (diff)
Use tempdir in example.py
-rw-r--r--py_bindings/example.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/py_bindings/example.py b/py_bindings/example.py
index 4abbd1d..d002a8a 100644
--- a/py_bindings/example.py
+++ b/py_bindings/example.py
@@ -1,6 +1,6 @@
+import tempfile
from pprint import pformat, pprint
-import log_db
-from log_db import Value, Type, Bound
+from log_db import Value, Type, Bound, DB
# TODO: This should be imported from the log_db module
# but exporting type aliases does not work automatically
@@ -27,10 +27,12 @@ class Inst:
def __repr__(self) -> str:
return pformat(self.__dict__)
+temp_dir = tempfile.TemporaryDirectory()
+
# Create a new database
-db = log_db.DB \
+db = DB \
.configure() \
- .data_dir("db") \
+ .data_dir(temp_dir.name) \
.schema([
("id", Type.int()),
("name", Type.string()),