dbagent-cli 0.8.7__tar.gz → 0.8.9__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 (81) hide show
  1. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/PKG-INFO +1 -1
  2. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/__init__.py +1 -1
  3. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/agent/generator.py +8 -20
  4. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/agent/pipeline.py +8 -7
  5. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/connectors/relational.py +66 -24
  6. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent_cli.egg-info/PKG-INFO +1 -1
  7. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/pyproject.toml +1 -1
  8. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/README.md +0 -0
  9. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/agent/confidence.py +0 -0
  10. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/agent/conversation.py +0 -0
  11. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/agent/doctor.py +0 -0
  12. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/agent/error_classifier.py +0 -0
  13. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/agent/recommender.py +0 -0
  14. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/agent/validator.py +0 -0
  15. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/cli.py +0 -0
  16. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/config.py +0 -0
  17. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/connectors/base.py +0 -0
  18. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/connectors/factory.py +0 -0
  19. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/connectors/mongo.py +0 -0
  20. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/execution/__init__.py +0 -0
  21. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/execution/cache.py +0 -0
  22. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/execution/changeset.py +0 -0
  23. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/execution/cost.py +0 -0
  24. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/execution/recovery.py +0 -0
  25. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/execution/sandbox.py +0 -0
  26. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/execution/streaming.py +0 -0
  27. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/llm/anthropic_provider.py +0 -0
  28. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/llm/auto_setup.py +0 -0
  29. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/llm/base.py +0 -0
  30. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/llm/deepseek_provider.py +0 -0
  31. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/llm/factory.py +0 -0
  32. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/llm/gemini_provider.py +0 -0
  33. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/llm/groq_provider.py +0 -0
  34. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/llm/mistral_provider.py +0 -0
  35. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/llm/mock_provider.py +0 -0
  36. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/llm/ollama_provider.py +0 -0
  37. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/llm/openai_provider.py +0 -0
  38. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/llm/openrouter_provider.py +0 -0
  39. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/schema/cache.py +0 -0
  40. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/schema/formatter.py +0 -0
  41. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/schema/graph.py +0 -0
  42. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/schema/models.py +0 -0
  43. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/schema/retriever.py +0 -0
  44. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/schema/selector.py +0 -0
  45. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/security/__init__.py +0 -0
  46. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/security/audit.py +0 -0
  47. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/security/environment.py +0 -0
  48. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/security/masking.py +0 -0
  49. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/security/modes.py +0 -0
  50. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/security/rbac.py +0 -0
  51. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/semantic/__init__.py +0 -0
  52. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/semantic/dictionary.py +0 -0
  53. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/semantic/templates.py +0 -0
  54. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/sql/__init__.py +0 -0
  55. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/sql/optimizer.py +0 -0
  56. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/sql/validator.py +0 -0
  57. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/ui/chat_screen.py +0 -0
  58. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/ui/console.py +0 -0
  59. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/ui/grid_window.py +0 -0
  60. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/ui/viewer.py +0 -0
  61. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent/ui/visualizer.py +0 -0
  62. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent_cli.egg-info/SOURCES.txt +0 -0
  63. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent_cli.egg-info/dependency_links.txt +0 -0
  64. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent_cli.egg-info/entry_points.txt +0 -0
  65. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent_cli.egg-info/requires.txt +0 -0
  66. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/dbagent_cli.egg-info/top_level.txt +0 -0
  67. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/setup.cfg +0 -0
  68. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/tests/test_cache.py +0 -0
  69. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/tests/test_cli.py +0 -0
  70. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/tests/test_connectors.py +0 -0
  71. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/tests/test_direct_sql.py +0 -0
  72. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/tests/test_doctor_and_viz.py +0 -0
  73. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/tests/test_generator.py +0 -0
  74. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/tests/test_graph.py +0 -0
  75. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/tests/test_providers.py +0 -0
  76. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/tests/test_recovery.py +0 -0
  77. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/tests/test_safety.py +0 -0
  78. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/tests/test_sandbox.py +0 -0
  79. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/tests/test_schema.py +0 -0
  80. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/tests/test_security.py +0 -0
  81. {dbagent_cli-0.8.7 → dbagent_cli-0.8.9}/tests/test_semantic.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dbagent-cli
3
- Version: 0.8.7
3
+ Version: 0.8.9
4
4
  Summary: Enterprise AI Database Copilot, Schema Graph Introspector & Autonomous Recovery Agent (CLI)
5
5
  Author: Santhosh Gupta
6
6
  Requires-Python: >=3.9
@@ -2,5 +2,5 @@
2
2
  DB-Agent: Universal Database Introspection and Script Generation AI Agent (CLI).
3
3
  """
4
4
 
5
- __version__ = "0.8.7"
5
+ __version__ = "0.8.9"
6
6
  __author__ = "Santhosh Gupta"
@@ -47,17 +47,12 @@ Generate ONLY the raw executable SQL query for the given database. No markdown f
47
47
  {schema_context}
48
48
 
49
49
  ### Rules:
50
- 1. Output ONLY the SQL query — nothing else. No ```sql fences, no explanations.
50
+ 1. Output ONLY the executable SQL query — nothing else. No ```sql fences, no explanations.
51
51
  2. Use the exact table and column names from the schema above.
52
52
  3. Use dialect-specific syntax for `{dialect_name}`.
53
53
  4. Write clean, optimized SQL with uppercase keywords.
54
- 5. If the user asks for recent/time-based data, use native datetime functions (e.g. for PostgreSQL: `NOW() - INTERVAL '1 hour'`, for SQLite: `datetime('now', '-1 hour')`, for MySQL: `NOW() - INTERVAL 1 HOUR`).
55
- 6. For queries inspecting PostgreSQL foreign key mappings or table relationships via system catalog, use standard joins:
56
- SELECT tc.table_name, kcu.column_name, ccu.table_name AS foreign_table_name, ccu.column_name AS foreign_column_name
57
- FROM information_schema.table_constraints tc
58
- JOIN information_schema.key_column_usage kcu ON tc.constraint_name = kcu.constraint_name
59
- JOIN information_schema.constraint_column_usage ccu ON tc.constraint_name = ccu.constraint_name
60
- WHERE tc.constraint_type = 'FOREIGN KEY';
54
+ 5. Always query the user's actual database tables and junction/mapping tables from the schema context, using foreign key relationships for JOINs.
55
+ 6. If the user asks for recent/time-based data, use native datetime functions (e.g. for PostgreSQL: `NOW() - INTERVAL '1 hour'`, for SQLite: `datetime('now', '-1 hour')`, for MySQL: `NOW() - INTERVAL 1 HOUR`).
61
56
  7. Always include appropriate WHERE clauses, JOINs, and ORDER BY as needed.
62
57
  8. Default to LIMIT 50 unless the user specifies a count.
63
58
  9. For status, active, or flag columns (e.g. `active`, `is_active`, `status`, `enabled`, `deleted`):
@@ -86,7 +81,7 @@ You are chatting with the user in the interactive database shell.
86
81
 
87
82
  # --- Architectural / Linkage analysis prompt ---
88
83
 
89
- ARCHITECTURE_SYSTEM_PROMPT = """You are DB-Agent, a Principal Database Architect, Data Modeler, and Systems Engineer.
84
+ ARCHITECTURE_SYSTEM_PROMPT = """You are DB-Agent, an elite Principal Database Architect, Data Modeler, and Systems Engineer.
90
85
  Target Database Context:
91
86
  - **Dialect**: {dialect_name}
92
87
  - **Database Name**: {database_name}
@@ -94,23 +89,16 @@ Target Database Context:
94
89
  ### Detailed Schema Sub-Graph Context (Tables, Columns, Primary Keys, Foreign Keys, Sample Data):
95
90
  {schema_context}
96
91
 
97
- The user is asking for architectural analysis, entity relationships, linkages, mappings, or how tables relate to each other in this database.
92
+ The user is asking a question regarding database architecture, entity relationships, linkages, mappings, data flows, or structural design.
98
93
 
99
- Provide a comprehensive, high-quality, professional Architectural Report structured as follows:
94
+ Analyze the provided schema and the user's question, and produce a clear, authoritative, and comprehensive architectural response structured as follows:
100
95
 
101
96
  ### 1. 🗺️ Entity-Relationship & Linkage Architecture Diagram
102
97
  Provide a clean, readable ASCII / Unicode box diagram showing the entities, relationship paths, cardinality (1:1, 1:N, N:M junction tables), and the exact connecting foreign keys / join keys.
103
- Example structure:
104
- ```text
105
- ┌──────────────┐ ┌──────────────────────┐ ┌───────────────┐
106
- │ ivis_user │ 1 ──── * │ ivis_tenant_user_map │ * ──── 1 │ ivis_tenant │
107
- └──────────────┘ └──────────────────────┘ └───────────────┘
108
- (pk_user_id) (fk_user_id) (pk_tenant_id)
109
- ```
110
98
 
111
99
  ### 2. 📐 Architectural & Theoretical Breakdown
112
- - Explain in clear theoretical and domain terms how the entities map to each other.
113
- - Highlight the mapping mechanism (direct foreign key vs junction/mapping table vs hierarchical tree).
100
+ - Explain in clear theoretical and domain terms how the entities map to each other in this database.
101
+ - Highlight the mapping mechanisms (direct foreign keys, junction/mapping tables, hierarchical ownership).
114
102
  - Detail the cardinality, tenant isolation, and user access models represented in the schema.
115
103
 
116
104
  ### 3. 🔍 How to Query & Verify Mappings (SQL Examples)
@@ -205,16 +205,17 @@ class QueryPipeline:
205
205
  # --- 1.2. Architectural / Linkage Analysis Path ---
206
206
  if result.intent == "analysis":
207
207
  try:
208
- cached = self.cache_mgr.load_cached_schema(self.db_id)
209
- if cached:
210
- schema = cached
211
- else:
212
- schema = self.connector.inspect_schema(include_samples=True, max_samples=2)
208
+ try:
209
+ exact, fuzzy = self.connector.resolve_tables(user_prompt)
210
+ except Exception:
211
+ exact, fuzzy = [], []
213
212
 
214
- result.schema = schema
213
+ sub_schema, join_steps = self._get_fast_schema_context(user_prompt, exact, fuzzy)
214
+ result.schema = sub_schema
215
+ result.join_steps = join_steps
215
216
  conv_history = self.conversation.format_context_for_prompt()
216
217
  result.message = self.generator.generate_analysis_response(
217
- schema=schema,
218
+ schema=sub_schema,
218
219
  user_prompt=user_prompt,
219
220
  conversation_history=conv_history,
220
221
  model=self.model,
@@ -200,16 +200,37 @@ class RelationalConnector(BaseConnector):
200
200
  lower_targets = {t.lower() for t in table_names}
201
201
  target_tables = [t for t in all_table_names if t.lower() in lower_targets]
202
202
 
203
- for t_name in target_tables:
204
- table_model = self._inspect_single_table(
205
- insp=insp,
206
- table_name=t_name,
207
- is_view=False,
208
- include_samples=include_samples,
209
- max_samples=max_samples,
210
- include_row_counts=include_row_counts,
211
- )
212
- tables.append(table_model)
203
+ if len(target_tables) > 1:
204
+ from concurrent.futures import ThreadPoolExecutor
205
+ with ThreadPoolExecutor(max_workers=min(len(target_tables), 8)) as executor:
206
+ futures = [
207
+ executor.submit(
208
+ self._inspect_single_table,
209
+ insp,
210
+ t_name,
211
+ False,
212
+ include_samples,
213
+ max_samples,
214
+ include_row_counts,
215
+ )
216
+ for t_name in target_tables
217
+ ]
218
+ for f in futures:
219
+ try:
220
+ tables.append(f.result())
221
+ except Exception:
222
+ pass
223
+ else:
224
+ for t_name in target_tables:
225
+ table_model = self._inspect_single_table(
226
+ insp=insp,
227
+ table_name=t_name,
228
+ is_view=False,
229
+ include_samples=include_samples,
230
+ max_samples=max_samples,
231
+ include_row_counts=include_row_counts,
232
+ )
233
+ tables.append(table_model)
213
234
 
214
235
  # 2. Inspect views
215
236
  if include_views:
@@ -220,20 +241,41 @@ class RelationalConnector(BaseConnector):
220
241
  lower_targets = {t.lower() for t in table_names}
221
242
  target_views = [v for v in all_view_names if v.lower() in lower_targets]
222
243
 
223
- for v_name in target_views:
224
- view_model = self._inspect_single_table(
225
- insp=insp,
226
- table_name=v_name,
227
- is_view=True,
228
- include_samples=include_samples,
229
- max_samples=max_samples,
230
- include_row_counts=include_row_counts,
231
- )
232
- try:
233
- view_model.view_definition = insp.get_view_definition(v_name)
234
- except Exception:
235
- pass
236
- tables.append(view_model)
244
+ if len(target_views) > 1:
245
+ from concurrent.futures import ThreadPoolExecutor
246
+ with ThreadPoolExecutor(max_workers=min(len(target_views), 6)) as executor:
247
+ view_futures = [
248
+ executor.submit(
249
+ self._inspect_single_table,
250
+ insp,
251
+ v_name,
252
+ True,
253
+ include_samples,
254
+ max_samples,
255
+ include_row_counts,
256
+ )
257
+ for v_name in target_views
258
+ ]
259
+ for f in view_futures:
260
+ try:
261
+ tables.append(f.result())
262
+ except Exception:
263
+ pass
264
+ else:
265
+ for v_name in target_views:
266
+ view_model = self._inspect_single_table(
267
+ insp=insp,
268
+ table_name=v_name,
269
+ is_view=True,
270
+ include_samples=include_samples,
271
+ max_samples=max_samples,
272
+ include_row_counts=include_row_counts,
273
+ )
274
+ try:
275
+ view_model.view_definition = insp.get_view_definition(v_name)
276
+ except Exception:
277
+ pass
278
+ tables.append(view_model)
237
279
 
238
280
  return DatabaseSchema(
239
281
  dialect_name=dialect_name,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dbagent-cli
3
- Version: 0.8.7
3
+ Version: 0.8.9
4
4
  Summary: Enterprise AI Database Copilot, Schema Graph Introspector & Autonomous Recovery Agent (CLI)
5
5
  Author: Santhosh Gupta
6
6
  Requires-Python: >=3.9
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dbagent-cli"
7
- version = "0.8.7"
7
+ version = "0.8.9"
8
8
  description = "Enterprise AI Database Copilot, Schema Graph Introspector & Autonomous Recovery Agent (CLI)"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
File without changes
File without changes
File without changes