From 83f5ccb5fe740767cb958357a6c925dd147652a1 Mon Sep 17 00:00:00 2001 From: Praneeth Bedapudi Date: Thu, 7 Nov 2024 10:39:10 +0530 Subject: [PATCH] optional auto_vacuum param Signed-off-by: Praneeth Bedapudi --- liteindex/defined_index.py | 18 +++++++++++++++--- setup.py | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/liteindex/defined_index.py b/liteindex/defined_index.py index eabd3ef..725edea 100644 --- a/liteindex/defined_index.py +++ b/liteindex/defined_index.py @@ -95,7 +95,14 @@ class Key: pass def __init__( - self, name, schema=None, db_path=None, ram_cache_mb=64, compression_level=None + self, + name, + schema=None, + db_path=None, + ram_cache_mb=64, + compression_level=None, + auto_vacuum=True, + auto_vacuum_increment=1000, ): if sqlite3.sqlite_version < "3.35.0": raise ValueError( @@ -107,6 +114,8 @@ def __init__( self.db_path = ":memory:" if db_path is None else db_path self.ram_cache_mb = ram_cache_mb self.compression_level = compression_level + self.auto_vacuum = auto_vacuum + self.auto_vacuum_increment = auto_vacuum_increment if self.name.startswith("__"): raise ValueError("Index name cannot start with '__'") @@ -150,8 +159,11 @@ def __connection(self): self.__local_storage.db_conn.execute("PRAGMA journal_mode=WAL") self.__local_storage.db_conn.execute("PRAGMA synchronous=NORMAL") - self.__local_storage.db_conn.execute("PRAGMA auto_vacuum=FULL") - self.__local_storage.db_conn.execute("PRAGMA auto_vacuum_increment=1000") + if self.auto_vacuum: + self.__local_storage.db_conn.execute("PRAGMA auto_vacuum=FULL") + self.__local_storage.db_conn.execute( + f"PRAGMA auto_vacuum_increment={self.auto_vacuum_increment}" + ) self.__local_storage.db_conn.execute( f"PRAGMA cache_size=-{self.ram_cache_mb * 1024}" diff --git a/setup.py b/setup.py index e6c4b48..08d1fcb 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ EMAIL = "praneeth@bpraneeth.com" AUTHOR = "BEDAPUDI PRANEETH" REQUIRES_PYTHON = ">=3.6.0" -VERSION = "0.0.3.2.dev5" +VERSION = "0.0.3.2.dev6" # What packages are required for this module to be executed? REQUIRED = []