thoth-dbmanager 0.4.1__tar.gz → 0.4.2__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.
Files changed (60) hide show
  1. {thoth_dbmanager-0.4.1/thoth_dbmanager.egg-info → thoth_dbmanager-0.4.2}/PKG-INFO +4 -1
  2. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/pyproject.toml +4 -2
  3. thoth_dbmanager-0.4.2/thoth_dbmanager/adapters/qdrant.py +189 -0
  4. thoth_dbmanager-0.4.2/thoth_dbmanager/plugins/qdrant.py +41 -0
  5. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2/thoth_dbmanager.egg-info}/PKG-INFO +4 -1
  6. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager.egg-info/SOURCES.txt +2 -0
  7. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager.egg-info/requires.txt +4 -0
  8. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager.egg-info/top_level.txt +1 -0
  9. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/LICENSE +0 -0
  10. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/MANIFEST.in +0 -0
  11. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/README.md +0 -0
  12. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/setup.cfg +0 -0
  13. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/tests/test_integration_new_architecture.py +0 -0
  14. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/tests/test_lsh_query.py +0 -0
  15. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/tests/test_new_architecture.py +0 -0
  16. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/tests/test_parameter_validation.py +0 -0
  17. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/tests/test_thoth_db_manager_base.py +0 -0
  18. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/tests/test_thoth_informix_manager.py +0 -0
  19. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/tests/test_thoth_mariadb_manager.py +0 -0
  20. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/tests/test_thoth_mysql_manager.py +0 -0
  21. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/tests/test_thoth_oracle_manager.py +0 -0
  22. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/tests/test_thoth_pg_manager.py +0 -0
  23. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/tests/test_thoth_sqlite_manager.py +0 -0
  24. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/tests/test_thoth_sqlserver_manager.py +0 -0
  25. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/tests/test_thoth_supabase_manager.py +0 -0
  26. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/ThothDbManager.py +0 -0
  27. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/__init__.py +0 -0
  28. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/adapters/__init__.py +0 -0
  29. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/adapters/mariadb.py +0 -0
  30. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/adapters/mysql.py +0 -0
  31. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/adapters/oracle.py +0 -0
  32. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/adapters/postgresql.py +0 -0
  33. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/adapters/sqlite.py +0 -0
  34. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/adapters/sqlserver.py +0 -0
  35. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/adapters/supabase.py +0 -0
  36. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/core/__init__.py +0 -0
  37. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/core/factory.py +0 -0
  38. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/core/interfaces.py +0 -0
  39. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/core/registry.py +0 -0
  40. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/documents.py +0 -0
  41. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/dynamic_imports.py +0 -0
  42. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/helpers/__init__.py +0 -0
  43. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/helpers/multi_db_generator.py +0 -0
  44. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/helpers/preprocess_values.py +0 -0
  45. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/helpers/schema.py +0 -0
  46. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/helpers/search.py +0 -0
  47. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/lsh/__init__.py +0 -0
  48. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/lsh/core.py +0 -0
  49. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/lsh/factory.py +0 -0
  50. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/lsh/manager.py +0 -0
  51. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/lsh/storage.py +0 -0
  52. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/plugins/__init__.py +0 -0
  53. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/plugins/mariadb.py +0 -0
  54. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/plugins/mysql.py +0 -0
  55. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/plugins/oracle.py +0 -0
  56. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/plugins/postgresql.py +0 -0
  57. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/plugins/sqlite.py +0 -0
  58. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/plugins/sqlserver.py +0 -0
  59. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager/plugins/supabase.py +0 -0
  60. {thoth_dbmanager-0.4.1 → thoth_dbmanager-0.4.2}/thoth_dbmanager.egg-info/dependency_links.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: thoth_dbmanager
3
- Version: 0.4.1
3
+ Version: 0.4.2
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
  License: MIT
@@ -45,6 +45,8 @@ Requires-Dist: supabase>=2.0.0; extra == "supabase"
45
45
  Requires-Dist: postgrest-py>=0.16.0; extra == "supabase"
46
46
  Requires-Dist: gotrue-py>=2.0.0; extra == "supabase"
47
47
  Provides-Extra: sqlite
48
+ Provides-Extra: qdrant
49
+ Requires-Dist: qdrant-client>=1.7.0; extra == "qdrant"
48
50
  Provides-Extra: all
49
51
  Requires-Dist: psycopg2-binary>=2.9.0; extra == "all"
50
52
  Requires-Dist: mysql-connector-python>=8.0.0; extra == "all"
@@ -55,6 +57,7 @@ Requires-Dist: informixdb>=2.2.0; extra == "all"
55
57
  Requires-Dist: supabase>=2.0.0; extra == "all"
56
58
  Requires-Dist: postgrest-py>=0.16.0; extra == "all"
57
59
  Requires-Dist: gotrue-py>=2.0.0; extra == "all"
60
+ Requires-Dist: qdrant-client>=1.7.0; extra == "all"
58
61
  Provides-Extra: dev
59
62
  Requires-Dist: pytest>=7.0.0; extra == "dev"
60
63
  Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "thoth_dbmanager"
7
- version = "0.4.1"
7
+ version = "0.4.2"
8
8
  authors = [
9
9
  { name="Marco Pancotti", email="mp@tylconsulting.it" },
10
10
  ]
@@ -43,6 +43,7 @@ oracle = ["cx_Oracle>=8.3.0"]
43
43
  informix = ["informixdb>=2.2.0"]
44
44
  supabase = ["supabase>=2.0.0", "postgrest-py>=0.16.0", "gotrue-py>=2.0.0"]
45
45
  sqlite = [] # Built into Python
46
+ qdrant = ["qdrant-client>=1.7.0"]
46
47
 
47
48
  # Convenience groups
48
49
  all = [
@@ -54,7 +55,8 @@ all = [
54
55
  "informixdb>=2.2.0",
55
56
  "supabase>=2.0.0",
56
57
  "postgrest-py>=0.16.0",
57
- "gotrue-py>=2.0.0"
58
+ "gotrue-py>=2.0.0",
59
+ "qdrant-client>=1.7.0"
58
60
  ]
59
61
 
60
62
  # Development dependencies
@@ -0,0 +1,189 @@
1
+ """
2
+ Qdrant adapter for Thoth SQL Database Manager.
3
+ """
4
+
5
+ from typing import Any, Dict, List, Optional, Union
6
+ from ..core.interfaces import DbAdapter
7
+
8
+
9
+ class QdrantAdapter(DbAdapter):
10
+ """
11
+ Qdrant vector database adapter implementation.
12
+ """
13
+
14
+ def __init__(self, **kwargs):
15
+ """Initialize Qdrant adapter with connection parameters."""
16
+ super().__init__()
17
+ self.host = kwargs.get('host', 'localhost')
18
+ self.port = kwargs.get('port', 6333)
19
+ self.api_key = kwargs.get('api_key')
20
+ self.collection_name = kwargs.get('collection_name', 'thoth_documents')
21
+ self._client = None
22
+
23
+ def connect(self) -> bool:
24
+ """Establish connection to Qdrant."""
25
+ try:
26
+ # Import qdrant_client here to avoid dependency issues
27
+ from qdrant_client import QdrantClient
28
+
29
+ if self.api_key:
30
+ self._client = QdrantClient(
31
+ host=self.host,
32
+ port=self.port,
33
+ api_key=self.api_key
34
+ )
35
+ else:
36
+ self._client = QdrantClient(
37
+ host=self.host,
38
+ port=self.port
39
+ )
40
+
41
+ # Test connection
42
+ self._client.get_collections()
43
+ return True
44
+ except Exception as e:
45
+ print(f"Failed to connect to Qdrant: {e}")
46
+ return False
47
+
48
+ def disconnect(self) -> None:
49
+ """Disconnect from Qdrant."""
50
+ if self._client:
51
+ self._client.close()
52
+ self._client = None
53
+
54
+ def execute_query(self, query: str, params: Optional[Dict] = None,
55
+ fetch: Union[str, int] = "all", timeout: int = 60) -> Any:
56
+ """
57
+ Execute a query against Qdrant.
58
+ Note: Qdrant doesn't use SQL, so this adapts the interface.
59
+ """
60
+ if not self._client:
61
+ raise RuntimeError("Not connected to Qdrant")
62
+
63
+ # This is a placeholder - adapt based on your specific needs
64
+ # Qdrant uses vector search, not SQL queries
65
+ return {"message": "Qdrant uses vector search, not SQL queries"}
66
+
67
+ def get_tables(self) -> List[Dict[str, str]]:
68
+ """Get collections (equivalent to tables in Qdrant)."""
69
+ if not self._client:
70
+ raise RuntimeError("Not connected to Qdrant")
71
+
72
+ try:
73
+ collections = self._client.get_collections()
74
+ return [
75
+ {
76
+ "table_name": collection.name,
77
+ "table_type": "COLLECTION"
78
+ }
79
+ for collection in collections.collections
80
+ ]
81
+ except Exception as e:
82
+ print(f"Error getting collections: {e}")
83
+ return []
84
+
85
+ def get_columns(self, table_name: str) -> List[Dict[str, Any]]:
86
+ """Get collection info (equivalent to columns in Qdrant)."""
87
+ if not self._client:
88
+ raise RuntimeError("Not connected to Qdrant")
89
+
90
+ try:
91
+ collection_info = self._client.get_collection(table_name)
92
+ return [
93
+ {
94
+ "column_name": "id",
95
+ "data_type": "UUID",
96
+ "is_nullable": False
97
+ },
98
+ {
99
+ "column_name": "vector",
100
+ "data_type": f"VECTOR({collection_info.config.params.vectors.size})",
101
+ "is_nullable": False
102
+ },
103
+ {
104
+ "column_name": "payload",
105
+ "data_type": "JSON",
106
+ "is_nullable": True
107
+ }
108
+ ]
109
+ except Exception as e:
110
+ print(f"Error getting collection info: {e}")
111
+ return []
112
+
113
+ def get_foreign_keys(self) -> List[Dict[str, str]]:
114
+ """Get foreign keys (not applicable for Qdrant)."""
115
+ return []
116
+
117
+ def get_unique_values(self) -> Dict[str, Dict[str, List[str]]]:
118
+ """Get unique values from collections."""
119
+ if not self._client:
120
+ raise RuntimeError("Not connected to Qdrant")
121
+
122
+ # This is a simplified implementation
123
+ # In practice, you'd need to scroll through points and extract unique payload values
124
+ return {}
125
+
126
+ def add_documentation(self, doc_type: str, content: Dict[str, Any]) -> str:
127
+ """Add documentation to Qdrant collection."""
128
+ if not self._client:
129
+ raise RuntimeError("Not connected to Qdrant")
130
+
131
+ try:
132
+ from qdrant_client.models import PointStruct
133
+ import uuid
134
+
135
+ # Generate a unique ID for the document
136
+ doc_id = str(uuid.uuid4())
137
+
138
+ # Create a point with the documentation content
139
+ point = PointStruct(
140
+ id=doc_id,
141
+ vector=content.get('vector', [0.0] * 384), # Default vector size
142
+ payload={
143
+ "doc_type": doc_type,
144
+ "content": content
145
+ }
146
+ )
147
+
148
+ # Upsert the point
149
+ self._client.upsert(
150
+ collection_name=self.collection_name,
151
+ points=[point]
152
+ )
153
+
154
+ return doc_id
155
+ except Exception as e:
156
+ print(f"Error adding documentation: {e}")
157
+ raise
158
+
159
+ def delete_collection(self, collection_name: str) -> bool:
160
+ """Delete a collection from Qdrant."""
161
+ if not self._client:
162
+ raise RuntimeError("Not connected to Qdrant")
163
+
164
+ try:
165
+ self._client.delete_collection(collection_name)
166
+ return True
167
+ except Exception as e:
168
+ print(f"Error deleting collection: {e}")
169
+ return False
170
+
171
+ def create_collection(self, collection_name: str, vector_size: int = 384) -> bool:
172
+ """Create a new collection in Qdrant."""
173
+ if not self._client:
174
+ raise RuntimeError("Not connected to Qdrant")
175
+
176
+ try:
177
+ from qdrant_client.models import VectorParams, Distance
178
+
179
+ self._client.create_collection(
180
+ collection_name=collection_name,
181
+ vectors_config=VectorParams(
182
+ size=vector_size,
183
+ distance=Distance.COSINE
184
+ )
185
+ )
186
+ return True
187
+ except Exception as e:
188
+ print(f"Error creating collection: {e}")
189
+ return False
@@ -0,0 +1,41 @@
1
+ """
2
+ Qdrant plugin for Thoth SQL Database Manager.
3
+ """
4
+
5
+ from typing import List
6
+ from ..core.interfaces import DbPlugin
7
+ from ..adapters.qdrant import QdrantAdapter
8
+
9
+
10
+ class QdrantPlugin(DbPlugin):
11
+ """Plugin for Qdrant vector database."""
12
+
13
+ plugin_name = "qdrant"
14
+ plugin_version = "1.0.0"
15
+ supported_db_types = ["qdrant"]
16
+ required_dependencies = ["qdrant-client"]
17
+
18
+ def create_adapter(self, **kwargs) -> QdrantAdapter:
19
+ """Create and return a QdrantAdapter instance."""
20
+ return QdrantAdapter(**kwargs)
21
+
22
+ def validate_connection_params(self, **kwargs) -> bool:
23
+ """Validate Qdrant connection parameters."""
24
+ required_params = ['host']
25
+
26
+ for param in required_params:
27
+ if param not in kwargs:
28
+ return False
29
+
30
+ # Validate host format
31
+ host = kwargs.get('host')
32
+ if not isinstance(host, str) or not host.strip():
33
+ return False
34
+
35
+ # Validate port if provided
36
+ port = kwargs.get('port')
37
+ if port is not None:
38
+ if not isinstance(port, int) or port <= 0 or port > 65535:
39
+ return False
40
+
41
+ return True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: thoth_dbmanager
3
- Version: 0.4.1
3
+ Version: 0.4.2
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
  License: MIT
@@ -45,6 +45,8 @@ Requires-Dist: supabase>=2.0.0; extra == "supabase"
45
45
  Requires-Dist: postgrest-py>=0.16.0; extra == "supabase"
46
46
  Requires-Dist: gotrue-py>=2.0.0; extra == "supabase"
47
47
  Provides-Extra: sqlite
48
+ Provides-Extra: qdrant
49
+ Requires-Dist: qdrant-client>=1.7.0; extra == "qdrant"
48
50
  Provides-Extra: all
49
51
  Requires-Dist: psycopg2-binary>=2.9.0; extra == "all"
50
52
  Requires-Dist: mysql-connector-python>=8.0.0; extra == "all"
@@ -55,6 +57,7 @@ Requires-Dist: informixdb>=2.2.0; extra == "all"
55
57
  Requires-Dist: supabase>=2.0.0; extra == "all"
56
58
  Requires-Dist: postgrest-py>=0.16.0; extra == "all"
57
59
  Requires-Dist: gotrue-py>=2.0.0; extra == "all"
60
+ Requires-Dist: qdrant-client>=1.7.0; extra == "all"
58
61
  Provides-Extra: dev
59
62
  Requires-Dist: pytest>=7.0.0; extra == "dev"
60
63
  Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
@@ -29,6 +29,7 @@ thoth_dbmanager/adapters/mariadb.py
29
29
  thoth_dbmanager/adapters/mysql.py
30
30
  thoth_dbmanager/adapters/oracle.py
31
31
  thoth_dbmanager/adapters/postgresql.py
32
+ thoth_dbmanager/adapters/qdrant.py
32
33
  thoth_dbmanager/adapters/sqlite.py
33
34
  thoth_dbmanager/adapters/sqlserver.py
34
35
  thoth_dbmanager/adapters/supabase.py
@@ -51,6 +52,7 @@ thoth_dbmanager/plugins/mariadb.py
51
52
  thoth_dbmanager/plugins/mysql.py
52
53
  thoth_dbmanager/plugins/oracle.py
53
54
  thoth_dbmanager/plugins/postgresql.py
55
+ thoth_dbmanager/plugins/qdrant.py
54
56
  thoth_dbmanager/plugins/sqlite.py
55
57
  thoth_dbmanager/plugins/sqlserver.py
56
58
  thoth_dbmanager/plugins/supabase.py
@@ -13,6 +13,7 @@ informixdb>=2.2.0
13
13
  supabase>=2.0.0
14
14
  postgrest-py>=0.16.0
15
15
  gotrue-py>=2.0.0
16
+ qdrant-client>=1.7.0
16
17
 
17
18
  [dev]
18
19
  pytest>=7.0.0
@@ -37,6 +38,9 @@ cx_Oracle>=8.3.0
37
38
  [postgresql]
38
39
  psycopg2-binary>=2.9.0
39
40
 
41
+ [qdrant]
42
+ qdrant-client>=1.7.0
43
+
40
44
  [sqlite]
41
45
 
42
46
  [sqlserver]
File without changes