thoth-dbmanager 0.4.8__py3-none-any.whl → 0.4.9__py3-none-any.whl

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.
@@ -143,7 +143,7 @@ class DbPlugin(ABC):
143
143
  def __init__(self, db_root_path: str, db_mode: str = "dev", **kwargs):
144
144
  """
145
145
  Initialize the database plugin.
146
-
146
+
147
147
  Args:
148
148
  db_root_path: Path to the database root directory
149
149
  db_mode: Database mode (dev, prod, etc.)
@@ -153,6 +153,16 @@ class DbPlugin(ABC):
153
153
  self.db_mode = db_mode
154
154
  self.adapter: Optional[DbAdapter] = None
155
155
  self._initialized = False
156
+
157
+ @property
158
+ def db_type(self) -> str:
159
+ """
160
+ Get the primary database type for this plugin.
161
+
162
+ Returns:
163
+ The first supported database type, or "unknown" if none specified
164
+ """
165
+ return self.supported_db_types[0] if self.supported_db_types else "unknown"
156
166
 
157
167
  @abstractmethod
158
168
  def create_adapter(self, **kwargs) -> DbAdapter:
@@ -100,10 +100,14 @@ class LshManager:
100
100
  if not self.storage_strategy.exists(self.lsh_base_path):
101
101
  # Show the actual file paths being checked for better debugging
102
102
  lsh_file = self.lsh_base_path.with_suffix('.pkl')
103
- minhashes_file = self.lsh_base_path.parent / f"{self.lsh_base_path.stem}_minhashes.pkl"
103
+ # Use the old naming convention for minhashes file
104
+ db_id = self.lsh_base_path.stem.replace('_lsh', '') if self.lsh_base_path.stem.endswith('_lsh') else self.lsh_base_path.stem
105
+ minhashes_file = self.lsh_base_path.parent / f"{db_id}_minhashes.pkl"
106
+ unique_values_file = self.lsh_base_path.parent / f"{db_id}_unique_values.pkl"
104
107
  logging.warning(f"LSH files not found. Expected files:")
105
108
  logging.warning(f" LSH file: {lsh_file}")
106
109
  logging.warning(f" Minhashes file: {minhashes_file}")
110
+ logging.warning(f" Unique values file: {unique_values_file}")
107
111
  return False
108
112
 
109
113
  lsh_data, minhashes_data = self.storage_strategy.load(self.lsh_base_path)
@@ -56,15 +56,19 @@ class PickleStorage(LshStorageStrategy):
56
56
  def save(self, lsh_data: Any, minhashes_data: Any, base_path: Path) -> None:
57
57
  """Save LSH data using pickle format."""
58
58
  lsh_path = base_path.with_suffix('.pkl')
59
- minhashes_path = base_path.parent / f"{base_path.stem}_minhashes.pkl"
60
-
59
+
60
+ # Use the old naming convention: {db_id}_minhashes.pkl instead of {db_id}_lsh_minhashes.pkl
61
+ # Extract db_id from base_path stem (remove _lsh suffix if present)
62
+ db_id = base_path.stem.replace('_lsh', '') if base_path.stem.endswith('_lsh') else base_path.stem
63
+ minhashes_path = base_path.parent / f"{db_id}_minhashes.pkl"
64
+
61
65
  # Ensure directory exists
62
66
  base_path.parent.mkdir(parents=True, exist_ok=True)
63
-
67
+
64
68
  # Save LSH data
65
69
  with open(lsh_path, 'wb') as f:
66
70
  pickle.dump(lsh_data, f)
67
-
71
+
68
72
  # Save minhashes data
69
73
  with open(minhashes_path, 'wb') as f:
70
74
  pickle.dump(minhashes_data, f)
@@ -72,32 +76,41 @@ class PickleStorage(LshStorageStrategy):
72
76
  def load(self, base_path: Path) -> Tuple[Optional[Any], Optional[Any]]:
73
77
  """Load LSH data from pickle files."""
74
78
  lsh_path = base_path.with_suffix('.pkl')
75
- minhashes_path = base_path.parent / f"{base_path.stem}_minhashes.pkl"
76
-
79
+
80
+ # Use the old naming convention: {db_id}_minhashes.pkl instead of {db_id}_lsh_minhashes.pkl
81
+ # Extract db_id from base_path stem (remove _lsh suffix if present)
82
+ db_id = base_path.stem.replace('_lsh', '') if base_path.stem.endswith('_lsh') else base_path.stem
83
+ minhashes_path = base_path.parent / f"{db_id}_minhashes.pkl"
84
+
77
85
  try:
78
86
  # Load LSH data
79
87
  with open(lsh_path, 'rb') as f:
80
88
  lsh_data = pickle.load(f)
81
-
89
+
82
90
  # Load minhashes data
83
91
  with open(minhashes_path, 'rb') as f:
84
92
  minhashes_data = pickle.load(f)
85
-
93
+
86
94
  return lsh_data, minhashes_data
87
-
95
+
88
96
  except (FileNotFoundError, pickle.PickleError):
89
97
  return None, None
90
98
 
91
99
  def exists(self, base_path: Path) -> bool:
92
100
  """Check if both LSH and minhashes pickle files exist."""
93
101
  lsh_path = base_path.with_suffix('.pkl')
94
- minhashes_path = base_path.parent / f"{base_path.stem}_minhashes.pkl"
102
+
103
+ # Use the old naming convention: {db_id}_minhashes.pkl instead of {db_id}_lsh_minhashes.pkl
104
+ # Extract db_id from base_path stem (remove _lsh suffix if present)
105
+ db_id = base_path.stem.replace('_lsh', '') if base_path.stem.endswith('_lsh') else base_path.stem
106
+ minhashes_path = base_path.parent / f"{db_id}_minhashes.pkl"
95
107
 
96
108
  # Add debug logging to help diagnose path issues
97
109
  import logging
98
110
  logger = logging.getLogger(__name__)
99
111
  logger.debug(f"Checking LSH files existence:")
100
112
  logger.debug(f" Base path: {base_path}")
113
+ logger.debug(f" DB ID: {db_id}")
101
114
  logger.debug(f" LSH path: {lsh_path} (exists: {lsh_path.exists()})")
102
115
  logger.debug(f" Minhashes path: {minhashes_path} (exists: {minhashes_path.exists()})")
103
116
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: thoth_dbmanager
3
- Version: 0.4.8
3
+ Version: 0.4.9
4
4
  Summary: A Python library for managing SQL databases with support for multiple database types, LSH-based similarity search, and a modern plugin architecture.
5
5
  Author-email: Marco Pancotti <mp@tylconsulting.it>
6
6
  Project-URL: Homepage, https://github.com/mptyl/thoth_dbmanager
@@ -12,7 +12,7 @@ thoth_dbmanager/adapters/sqlserver.py,sha256=V555kUH54Fb1Atow0BfvbSHmoSwGnrB_RJG
12
12
  thoth_dbmanager/adapters/supabase.py,sha256=bl2C6LpOpykPF3vIbdNRDk43aXLADzSk0wQuwTcEHZA,10348
13
13
  thoth_dbmanager/core/__init__.py,sha256=FlqNW0GZNv1rnwNgyXGzveLqaw0Z90y5AKhR_1DvHBE,269
14
14
  thoth_dbmanager/core/factory.py,sha256=sLj8tKI1ADqSlnU5F0NRtHHtpSimnATuwAqUYx5dfxI,9694
15
- thoth_dbmanager/core/interfaces.py,sha256=x2eHhIIQmrDEnt_0Ll3GicVWVI_rQip_x5k5sNwirFM,9280
15
+ thoth_dbmanager/core/interfaces.py,sha256=wZpKVQJdwMlAsHTQMB7yVviD2-N_dlOe19F-GhgEoGE,9576
16
16
  thoth_dbmanager/core/registry.py,sha256=2E9btPrPVnfI4z4JauKVEkN8mp8qy5gIVm3kKxUUD5E,7960
17
17
  thoth_dbmanager/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  thoth_dbmanager/helpers/multi_db_generator.py,sha256=LOrWEqh-RTVZXPF7vrlF6BmBGh1XC09kM6XkqkFNPQ4,23232
@@ -22,8 +22,8 @@ thoth_dbmanager/helpers/search.py,sha256=k04L7clSPfeQOlq_ifsH3PZ21ZK-rujh_Qy4hWr
22
22
  thoth_dbmanager/lsh/__init__.py,sha256=zAUTRuRX4MNc2nU93tTBkT2_IVL7OBkBL0WZPPgO3Ec,555
23
23
  thoth_dbmanager/lsh/core.py,sha256=171FqHW7ItAqAPk6g_AoayKTE3Bs1rRZxnt55MJVzjY,6813
24
24
  thoth_dbmanager/lsh/factory.py,sha256=2Bpkk-OygjaptZAw1yysxO1cxG3QTxmJ1yFGcXHqX3w,2411
25
- thoth_dbmanager/lsh/manager.py,sha256=tdTY4X3Hu7gOFd-iNCT410Fg-wIZ-XdzBu5YzZ9nehA,6150
26
- thoth_dbmanager/lsh/storage.py,sha256=9n-2qoHaqJ87SnZtKY58dUFhGDIIXGj5ydkKTX-rWfk,3759
25
+ thoth_dbmanager/lsh/manager.py,sha256=LGrKbGKiBuISlNXaU4Yxfc_BqJfN27MaXapJbzEAjJQ,6513
26
+ thoth_dbmanager/lsh/storage.py,sha256=qei6fwpmRCBSS8CRtDlnZCuWEmyuOK9gVSTkEJdX0eI,4543
27
27
  thoth_dbmanager/plugins/__init__.py,sha256=98iKwNiKnFFeJfw0qLGVOrP2Mo2wGPAolsx7R2B3emA,592
28
28
  thoth_dbmanager/plugins/mariadb.py,sha256=ElYa4Rexwrofcjcs0UQKan8fZpbU6-n9zghYR9SgRb4,17975
29
29
  thoth_dbmanager/plugins/mysql.py,sha256=mbDsIDV2H_BWYANU4JHMsUkxLQICuGtjKTTPbig2Ngs,16546
@@ -32,8 +32,8 @@ thoth_dbmanager/plugins/postgresql.py,sha256=pI1W9oHpQty8tHMoEDcsOT-Msv6S4aoFcAr
32
32
  thoth_dbmanager/plugins/sqlite.py,sha256=iMlOH4XMEY-Ac3yrs1HzjKaR4km1DxLDwAEjGZzM0Cc,6504
33
33
  thoth_dbmanager/plugins/sqlserver.py,sha256=mMb3F5FmSWV02FZwj-Ult-2TjuyeVA4Fl1iME1dbgLU,5289
34
34
  thoth_dbmanager/plugins/supabase.py,sha256=mWlaGAdpywx4-pU4Ffpmn24ze8sg0sM5kc6bFDoeYRg,8645
35
- thoth_dbmanager-0.4.8.dist-info/licenses/LICENSE,sha256=81-BOzGgwtY1XdYfkwMQB87AkOGXI9OMq0kjNcZA4UE,1071
36
- thoth_dbmanager-0.4.8.dist-info/METADATA,sha256=3KNrltdL1_d6l1Jd8Y4WBYgIUCESLgfx_5f3PGqgbnc,12246
37
- thoth_dbmanager-0.4.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
38
- thoth_dbmanager-0.4.8.dist-info/top_level.txt,sha256=b9ttxm9RUc0KUCASEKRx6FqoREYJ1-KZWSpNuaM0uQ4,16
39
- thoth_dbmanager-0.4.8.dist-info/RECORD,,
35
+ thoth_dbmanager-0.4.9.dist-info/licenses/LICENSE,sha256=81-BOzGgwtY1XdYfkwMQB87AkOGXI9OMq0kjNcZA4UE,1071
36
+ thoth_dbmanager-0.4.9.dist-info/METADATA,sha256=tdNXYo8QmI9els7dgE97lrb9X1-kHacvW3cl4MI4uZo,12246
37
+ thoth_dbmanager-0.4.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
38
+ thoth_dbmanager-0.4.9.dist-info/top_level.txt,sha256=b9ttxm9RUc0KUCASEKRx6FqoREYJ1-KZWSpNuaM0uQ4,16
39
+ thoth_dbmanager-0.4.9.dist-info/RECORD,,