jsonjsdb 0.7.1__tar.gz → 0.7.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {jsonjsdb-0.7.1 → jsonjsdb-0.7.3}/PKG-INFO +4 -1
- {jsonjsdb-0.7.1 → jsonjsdb-0.7.3}/README.md +3 -0
- {jsonjsdb-0.7.1 → jsonjsdb-0.7.3}/pyproject.toml +1 -1
- {jsonjsdb-0.7.1 → jsonjsdb-0.7.3}/src/jsonjsdb/database.py +5 -3
- {jsonjsdb-0.7.1 → jsonjsdb-0.7.3}/src/jsonjsdb/evolution.py +4 -1
- {jsonjsdb-0.7.1 → jsonjsdb-0.7.3}/src/jsonjsdb/writer.py +12 -4
- {jsonjsdb-0.7.1 → jsonjsdb-0.7.3}/.gitignore +0 -0
- {jsonjsdb-0.7.1 → jsonjsdb-0.7.3}/LICENSE +0 -0
- {jsonjsdb-0.7.1 → jsonjsdb-0.7.3}/src/jsonjsdb/__init__.py +0 -0
- {jsonjsdb-0.7.1 → jsonjsdb-0.7.3}/src/jsonjsdb/loader.py +0 -0
- {jsonjsdb-0.7.1 → jsonjsdb-0.7.3}/src/jsonjsdb/py.typed +0 -0
- {jsonjsdb-0.7.1 → jsonjsdb-0.7.3}/src/jsonjsdb/table.py +0 -0
- {jsonjsdb-0.7.1 → jsonjsdb-0.7.3}/src/jsonjsdb/types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: jsonjsdb
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.3
|
|
4
4
|
Summary: Python library for JSONJS database loading
|
|
5
5
|
Project-URL: Homepage, https://github.com/datannur/jsonjsdb
|
|
6
6
|
Project-URL: Repository, https://github.com/datannur/jsonjsdb
|
|
@@ -174,6 +174,9 @@ db.save(track_evolution=False)
|
|
|
174
174
|
|
|
175
175
|
# Use Excel as source (for easy editing of logs)
|
|
176
176
|
db.save(evolution_xlsx=Path("path/to/evolution.xlsx"))
|
|
177
|
+
|
|
178
|
+
# Override timestamp for deterministic outputs (useful for testing)
|
|
179
|
+
db.save(timestamp=1741186800)
|
|
177
180
|
```
|
|
178
181
|
|
|
179
182
|
When `evolution_xlsx` is provided:
|
|
@@ -149,6 +149,9 @@ db.save(track_evolution=False)
|
|
|
149
149
|
|
|
150
150
|
# Use Excel as source (for easy editing of logs)
|
|
151
151
|
db.save(evolution_xlsx=Path("path/to/evolution.xlsx"))
|
|
152
|
+
|
|
153
|
+
# Override timestamp for deterministic outputs (useful for testing)
|
|
154
|
+
db.save(timestamp=1741186800)
|
|
152
155
|
```
|
|
153
156
|
|
|
154
157
|
When `evolution_xlsx` is provided:
|
|
@@ -106,6 +106,7 @@ class Jsonjsdb:
|
|
|
106
106
|
*,
|
|
107
107
|
track_evolution: bool = True,
|
|
108
108
|
evolution_xlsx: Path | str | None = None,
|
|
109
|
+
timestamp: int | None = None,
|
|
109
110
|
) -> None:
|
|
110
111
|
"""Save all tables to disk with optional evolution tracking.
|
|
111
112
|
|
|
@@ -116,6 +117,7 @@ class Jsonjsdb:
|
|
|
116
117
|
path: Target directory path (optional if already loaded from path)
|
|
117
118
|
track_evolution: Enable change tracking (default: True)
|
|
118
119
|
evolution_xlsx: Optional path for evolution.xlsx output
|
|
120
|
+
timestamp: Optional timestamp override for deterministic outputs
|
|
119
121
|
"""
|
|
120
122
|
save_path = Path(path) if path else self._path
|
|
121
123
|
|
|
@@ -131,7 +133,7 @@ class Jsonjsdb:
|
|
|
131
133
|
self._path is not None and save_path.resolve() == self._path.resolve()
|
|
132
134
|
)
|
|
133
135
|
|
|
134
|
-
|
|
136
|
+
ts = timestamp if timestamp is not None else get_timestamp()
|
|
135
137
|
new_entries: list[EvolutionEntry] = []
|
|
136
138
|
|
|
137
139
|
table_names = []
|
|
@@ -143,7 +145,7 @@ class Jsonjsdb:
|
|
|
143
145
|
# Track evolution if enabled
|
|
144
146
|
if track_evolution:
|
|
145
147
|
old_df = self._get_old_table(save_path, name, same_path)
|
|
146
|
-
entries = compare_datasets(old_df, persistable_df,
|
|
148
|
+
entries = compare_datasets(old_df, persistable_df, ts, name)
|
|
147
149
|
new_entries.extend(entries)
|
|
148
150
|
|
|
149
151
|
write_table_json(persistable_df, save_path / f"{name}.json")
|
|
@@ -162,7 +164,7 @@ class Jsonjsdb:
|
|
|
162
164
|
if "evolution" not in table_names:
|
|
163
165
|
table_names.append("evolution")
|
|
164
166
|
|
|
165
|
-
write_table_index(table_names, save_path / "__table__.json")
|
|
167
|
+
write_table_index(table_names, save_path / "__table__.json", ts)
|
|
166
168
|
|
|
167
169
|
self._path = save_path
|
|
168
170
|
|
|
@@ -126,9 +126,12 @@ def compare_datasets(
|
|
|
126
126
|
if entity.startswith("__"):
|
|
127
127
|
return entries
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
# Skip tracking for initial creation (no previous data)
|
|
130
|
+
if old_df.is_empty():
|
|
130
131
|
return entries
|
|
131
132
|
|
|
133
|
+
# Normalize IDs for consistent comparison
|
|
134
|
+
|
|
132
135
|
# Normalize id columns to string for consistent comparison
|
|
133
136
|
old_df = _normalize_id_column(old_df)
|
|
134
137
|
new_df = _normalize_id_column(new_df)
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import json
|
|
4
4
|
import time
|
|
5
5
|
from pathlib import Path
|
|
6
|
-
from typing import Any
|
|
6
|
+
from typing import Any, Optional
|
|
7
7
|
|
|
8
8
|
import polars as pl
|
|
9
9
|
|
|
@@ -33,9 +33,17 @@ def write_table_jsonjs(df: pl.DataFrame, table_name: str, path: Path) -> None:
|
|
|
33
33
|
f.write(content)
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
def write_table_index(
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
def write_table_index(
|
|
37
|
+
tables: list[str], path: Path, timestamp: Optional[int] = None
|
|
38
|
+
) -> None:
|
|
39
|
+
"""Write __table__.json with table metadata.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
tables: List of table names to include
|
|
43
|
+
path: Path to write __table__.json
|
|
44
|
+
timestamp: Optional timestamp override (uses current time if None)
|
|
45
|
+
"""
|
|
46
|
+
now = timestamp if timestamp is not None else int(time.time())
|
|
39
47
|
entries = [{"name": name, "last_modif": now} for name in sorted(tables)]
|
|
40
48
|
|
|
41
49
|
with open(path, "w") as f:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|