example/example_8.pyPython30 lines
example_8.py
Persistence-only hash-index and native-WAL wrappers
example/example_8.py
Pythonfrom pathlib import Path
from tempfile import TemporaryDirectory
import storq
def main() -> None:
with TemporaryDirectory() as directory:
root = Path(directory)
index = storq.HashIndex("sample-index", root / "sample.index")
index.load()
index.save()
print("Created empty persisted index:", (root / "sample.index").exists())
database_path = root / "sample.storq"
wal = storq.NativeWAL(database_path)
wal.open()
print("Native WAL last LSN:", wal.last_lsn)
wal.sync()
print(
"Python bindings expose only HashIndex.load/save and "
"NativeWAL.open/sync/last_lsn; they do not expose index lookup "
"or WAL record append/read.",
)
if __name__ == "__main__":
main()
