natquery 1.0.1__tar.gz → 2.0.0__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 (95) hide show
  1. natquery-2.0.0/PKG-INFO +112 -0
  2. natquery-2.0.0/README.md +67 -0
  3. natquery-2.0.0/pyproject.toml +130 -0
  4. natquery-2.0.0/src/natquery/__init__.py +17 -0
  5. natquery-2.0.0/src/natquery/access/enforcer.py +517 -0
  6. natquery-2.0.0/src/natquery/access/functions.py +158 -0
  7. natquery-2.0.0/src/natquery/access/policy.py +437 -0
  8. natquery-2.0.0/src/natquery/access/result_guard.py +50 -0
  9. natquery-2.0.0/src/natquery/access/schema_view.py +123 -0
  10. natquery-2.0.0/src/natquery/app.py +111 -0
  11. natquery-2.0.0/src/natquery/audit/log.py +169 -0
  12. natquery-2.0.0/src/natquery/auth/base.py +74 -0
  13. natquery-2.0.0/src/natquery/auth/hashing.py +82 -0
  14. natquery-2.0.0/src/natquery/auth/local.py +78 -0
  15. natquery-2.0.0/src/natquery/auth/models.py +30 -0
  16. natquery-2.0.0/src/natquery/auth/session.py +98 -0
  17. natquery-2.0.0/src/natquery/auth/user_store.py +162 -0
  18. natquery-2.0.0/src/natquery/backends/base.py +77 -0
  19. natquery-2.0.0/src/natquery/backends/postgres.py +285 -0
  20. natquery-2.0.0/src/natquery/cli/admin.py +348 -0
  21. natquery-2.0.0/src/natquery/cli/commands.py +165 -0
  22. {natquery-1.0.1 → natquery-2.0.0}/src/natquery/cli/formatter.py +4 -3
  23. natquery-2.0.0/src/natquery/cli/main.py +137 -0
  24. natquery-2.0.0/src/natquery/cli/shell.py +202 -0
  25. natquery-2.0.0/src/natquery/config/paths.py +55 -0
  26. natquery-2.0.0/src/natquery/config/settings.py +144 -0
  27. natquery-2.0.0/src/natquery/errors.py +110 -0
  28. natquery-2.0.0/src/natquery/examples/erp_sample.sql +49 -0
  29. natquery-2.0.0/src/natquery/examples/policy.example.yaml +76 -0
  30. natquery-2.0.0/src/natquery/examples/semantics.example.json +11 -0
  31. natquery-2.0.0/src/natquery/execution/optimizer.py +30 -0
  32. natquery-2.0.0/src/natquery/execution/query_planner.py +22 -0
  33. natquery-2.0.0/src/natquery/llm/base.py +33 -0
  34. natquery-2.0.0/src/natquery/llm/generator.py +69 -0
  35. natquery-2.0.0/src/natquery/llm/groq_provider.py +47 -0
  36. natquery-2.0.0/src/natquery/observability/logger.py +69 -0
  37. natquery-2.0.0/src/natquery/orchestration/error_classifier.py +30 -0
  38. natquery-2.0.0/src/natquery/orchestration/pipeline.py +415 -0
  39. natquery-2.0.0/src/natquery/orchestration/types.py +21 -0
  40. natquery-2.0.0/src/natquery/prompt/builder.py +229 -0
  41. natquery-2.0.0/src/natquery/schema/__init__.py +0 -0
  42. natquery-2.0.0/src/natquery/schema/formatter.py +42 -0
  43. natquery-2.0.0/src/natquery/schema/knowledge_base.py +84 -0
  44. natquery-2.0.0/src/natquery/schema/retriever.py +126 -0
  45. natquery-2.0.0/src/natquery/schema/store.py +43 -0
  46. natquery-2.0.0/src/natquery/schema/value_hints.py +79 -0
  47. natquery-2.0.0/src/natquery/security/__init__.py +0 -0
  48. natquery-2.0.0/src/natquery/security/input_guard.py +88 -0
  49. natquery-2.0.0/src/natquery/security/rate_limit.py +35 -0
  50. natquery-2.0.0/src/natquery/security/redaction.py +52 -0
  51. natquery-2.0.0/src/natquery.egg-info/PKG-INFO +112 -0
  52. natquery-2.0.0/src/natquery.egg-info/SOURCES.txt +69 -0
  53. {natquery-1.0.1 → natquery-2.0.0}/src/natquery.egg-info/requires.txt +4 -0
  54. natquery-1.0.1/PKG-INFO +0 -148
  55. natquery-1.0.1/README.md +0 -108
  56. natquery-1.0.1/pyproject.toml +0 -76
  57. natquery-1.0.1/src/natquery/cli/commands.py +0 -259
  58. natquery-1.0.1/src/natquery/cli/main.py +0 -51
  59. natquery-1.0.1/src/natquery/cli/shell.py +0 -135
  60. natquery-1.0.1/src/natquery/config/connection.py +0 -123
  61. natquery-1.0.1/src/natquery/config/settings.py +0 -100
  62. natquery-1.0.1/src/natquery/execution/engine.py +0 -29
  63. natquery-1.0.1/src/natquery/execution/explain.py +0 -51
  64. natquery-1.0.1/src/natquery/llm/client.py +0 -37
  65. natquery-1.0.1/src/natquery/llm/self_corrector.py +0 -84
  66. natquery-1.0.1/src/natquery/observability/logger.py +0 -109
  67. natquery-1.0.1/src/natquery/observability/performance_api.py +0 -58
  68. natquery-1.0.1/src/natquery/orchestration/error_classifier.py +0 -29
  69. natquery-1.0.1/src/natquery/orchestration/error_handler.py +0 -81
  70. natquery-1.0.1/src/natquery/orchestration/pipeline.py +0 -192
  71. natquery-1.0.1/src/natquery/orchestration/workspace.py +0 -44
  72. natquery-1.0.1/src/natquery/prompt/builder.py +0 -27
  73. natquery-1.0.1/src/natquery/schema/extractor.py +0 -80
  74. natquery-1.0.1/src/natquery/schema/formatter.py +0 -52
  75. natquery-1.0.1/src/natquery/security/validator.py +0 -20
  76. natquery-1.0.1/src/natquery.egg-info/PKG-INFO +0 -148
  77. natquery-1.0.1/src/natquery.egg-info/SOURCES.txt +0 -42
  78. {natquery-1.0.1 → natquery-2.0.0}/LICENSE +0 -0
  79. {natquery-1.0.1 → natquery-2.0.0}/setup.cfg +0 -0
  80. {natquery-1.0.1/src/natquery → natquery-2.0.0/src/natquery/access}/__init__.py +0 -0
  81. {natquery-1.0.1/src/natquery/cli → natquery-2.0.0/src/natquery/audit}/__init__.py +0 -0
  82. {natquery-1.0.1/src/natquery/config → natquery-2.0.0/src/natquery/auth}/__init__.py +0 -0
  83. {natquery-1.0.1/src/natquery/execution → natquery-2.0.0/src/natquery/backends}/__init__.py +0 -0
  84. {natquery-1.0.1/src/natquery/llm → natquery-2.0.0/src/natquery/cli}/__init__.py +0 -0
  85. {natquery-1.0.1/src/natquery/ml → natquery-2.0.0/src/natquery/config}/__init__.py +0 -0
  86. {natquery-1.0.1/src/natquery/observability → natquery-2.0.0/src/natquery/execution}/__init__.py +0 -0
  87. {natquery-1.0.1/src/natquery/orchestration → natquery-2.0.0/src/natquery/llm}/__init__.py +0 -0
  88. {natquery-1.0.1/src/natquery/prompt → natquery-2.0.0/src/natquery/observability}/__init__.py +0 -0
  89. {natquery-1.0.1 → natquery-2.0.0}/src/natquery/observability/cost_analyzer.py +0 -0
  90. {natquery-1.0.1 → natquery-2.0.0}/src/natquery/observability/index_recommender.py +0 -0
  91. {natquery-1.0.1/src/natquery/schema → natquery-2.0.0/src/natquery/orchestration}/__init__.py +0 -0
  92. {natquery-1.0.1/src/natquery/security → natquery-2.0.0/src/natquery/prompt}/__init__.py +0 -0
  93. {natquery-1.0.1 → natquery-2.0.0}/src/natquery.egg-info/dependency_links.txt +0 -0
  94. {natquery-1.0.1 → natquery-2.0.0}/src/natquery.egg-info/entry_points.txt +0 -0
  95. {natquery-1.0.1 → natquery-2.0.0}/src/natquery.egg-info/top_level.txt +0 -0
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.4
2
+ Name: natquery
3
+ Version: 2.0.0
4
+ Summary: Ask PostgreSQL questions in plain English through a secure CLI with authentication, role-based access control and tamper-evident auditing
5
+ Author-email: Tanmai Raghava <tanmairaghava@kgpian.iitkgp.ac.in>, Krishna Chaitanya <krish89@kgpian.iitkgp.ac.in>, Thania Joshi <thaniavjoshi@kgpian.iitkgp.ac.in>, Lokeswara Reddy <lokeswarareddy2006@gmail.com>, Manasa Vankam <vankammanasa45@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/N-T-Raghava/NatQuery
8
+ Project-URL: Documentation, https://github.com/N-T-Raghava/NatQuery#readme
9
+ Project-URL: Repository, https://github.com/N-T-Raghava/NatQuery
10
+ Project-URL: Issues, https://github.com/N-T-Raghava/NatQuery/issues
11
+ Project-URL: Changelog, https://github.com/N-T-Raghava/NatQuery/blob/main/CHANGELOG.md
12
+ Keywords: nlp,database,postgres,natural-language,cli,llm,rbac,security,erp
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: System Administrators
17
+ Classifier: Natural Language :: English
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Topic :: Database
25
+ Classifier: Topic :: Security
26
+ Classifier: Topic :: Utilities
27
+ Requires-Python: >=3.10
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Requires-Dist: psycopg2-binary>=2.9.0
31
+ Requires-Dist: sqlglot<31,>=25.34.0
32
+ Requires-Dist: groq>=0.4.0
33
+ Requires-Dist: rich>=13.0.0
34
+ Requires-Dist: PyYAML>=6.0
35
+ Provides-Extra: dev
36
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
37
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
38
+ Requires-Dist: pytest-timeout>=2.1.0; extra == "dev"
39
+ Requires-Dist: hypothesis>=6.100.0; extra == "dev"
40
+ Requires-Dist: black==25.1.0; extra == "dev"
41
+ Requires-Dist: ruff==0.15.6; extra == "dev"
42
+ Requires-Dist: build>=1.0.0; extra == "dev"
43
+ Requires-Dist: twine>=4.0.0; extra == "dev"
44
+ Dynamic: license-file
45
+
46
+ # NatQuery
47
+
48
+ [![PyPI Version](https://img.shields.io/pypi/v/natquery)](https://pypi.org/project/natquery/)
49
+ [![PyPI Downloads](https://img.shields.io/pepy/dt/natquery)](https://pypi.org/project/natquery/)
50
+ [![CI](https://github.com/N-T-Raghava/NatQuery/actions/workflows/ci.yml/badge.svg)](https://github.com/N-T-Raghava/NatQuery/actions/workflows/ci.yml)
51
+ [![codecov](https://codecov.io/gh/N-T-Raghava/natquery/graph/badge.svg?token=KZIEXD9ALC)](https://codecov.io/gh/N-T-Raghava/natquery)
52
+ [![Code Style: Black](https://img.shields.io/badge/code%20style-black-000000)](https://github.com/psf/black)
53
+ [![Lint: Ruff](https://img.shields.io/badge/lint-ruff-261230)](https://github.com/astral-sh/ruff)
54
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE)
55
+
56
+ Ask PostgreSQL questions in plain English. NatQuery turns the question into SQL with an LLM, then **never runs the LLM's SQL**: the SQL is parsed, checked against the caller's role, rewritten with row filters, masks and limits, regenerated, and only then executed.
57
+
58
+ - **Authentication and roles** (student / teacher / admin or your own), defined in a YAML policy with inheritance, column grants, masks, and row filters bound to the caller's identity.
59
+ - **Leak-resistant by construction**: hidden tables and columns are absent from the LLM prompt and fail to resolve in the enforcer.
60
+ - **Tamper-evident audit log** (hash-chained, optional HMAC).
61
+ - **Several schemas** in one connection (`schema.table`, `fin.*` grants) and **database row-level security** driven by the caller's identity.
62
+ - **Pluggable**: auth provider, database backend, LLM, rate limiter, session store, input guard.
63
+ - **Bounded repair loop**: if the enforcer rejects a fixable query, the LLM gets the (sanitised) reason and tries again, at most twice.
64
+
65
+ See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) for the security model and known limits.
66
+
67
+ ## Benchmark
68
+
69
+ On BIRD Mini-Dev (PostgreSQL, 500 questions) with the open `gpt-oss-120b` model, NatQuery scores **45.6% official execution accuracy** with the security layer on, at about 1.1 s per question and $0.0004 per question. Full results and limitations: [docs/BIRD_REPORT.md](docs/BIRD_REPORT.md). Reproduction: [benchmarks/bird](benchmarks/bird/README.md).
70
+
71
+ ## Security testing
72
+
73
+ On AdventureWorks with three roles, 227 hostile SQL queries (560 role-by-query runs), 40 auth/audit checks and 30 natural-language attacks produced **zero leaks**; an unprotected text-to-SQL leaked on 7 of 8 comparable attacks. Details and limitations: [docs/SECURITY_REPORT.md](docs/SECURITY_REPORT.md). Reproduction: [benchmarks/security](benchmarks/security/README.md).
74
+
75
+ ## ERP test bed
76
+
77
+ `erp/` holds a synthetic university ERP (10 schemas, 87 tables, about 368,000 rows, 10 roles, logins in SQL, row-level security) and a 40-question benchmark in three difficulty levels. It exercises multi-schema support (`db_schemas`, `schema.table`, `fin.*` grants) and database-side row-level security (`db_session_vars`). Database checks: 51 of 51; no-LLM dry run through the full pipeline: 41 of 41. Details: [erp/README.md](erp/README.md), questions: [erp/ERP_Benchmark_Questions.md](erp/ERP_Benchmark_Questions.md).
78
+
79
+ ## Install and test
80
+
81
+ ```bash
82
+ pip install -e ".[dev]"
83
+ pytest # ~850 tests, 90% coverage gate
84
+ natquery --help
85
+ ```
86
+
87
+ ## Licence
88
+
89
+ MIT. BIRD benchmark data under `benchmarks/bird/results` is CC BY-SA 4.0.
90
+
91
+ ## Quick start
92
+
93
+ ```bash
94
+ pip install natquery
95
+ natquery connect # database, schema and LLM key (kept in your workspace, never in the repo)
96
+ natquery policy init # writes an example policy.yaml and semantics.json to edit
97
+ natquery user add alice --roles student # see `natquery user add --help`
98
+ natquery # interactive shell: log in, then ask questions in English
99
+ ```
100
+
101
+ ## Repository layout
102
+
103
+ | Path | Content |
104
+ |---|---|
105
+ | `src/natquery/` | The library (auth, access control, enforcer, audit, backends, LLM, CLI) |
106
+ | `tests/` | Unit and integration tests |
107
+ | `benchmarks/bird/` | BIRD Mini-Dev accuracy and efficiency benchmark |
108
+ | `benchmarks/security/` | AdventureWorks security benchmark (hostile SQL, auth, natural-language attacks) |
109
+ | `benchmarks/benchmarker.py`, `benchmarks/results/` | Earlier v1 query-optimisation benchmark and its results |
110
+ | `erp/` | Synthetic university ERP test bed (87 tables, row-level security) and 40-question benchmark |
111
+ | `docs/` | Architecture and security model, BIRD report, security report |
112
+ | `report/` | LaTeX source of the B.Tech project report |
@@ -0,0 +1,67 @@
1
+ # NatQuery
2
+
3
+ [![PyPI Version](https://img.shields.io/pypi/v/natquery)](https://pypi.org/project/natquery/)
4
+ [![PyPI Downloads](https://img.shields.io/pepy/dt/natquery)](https://pypi.org/project/natquery/)
5
+ [![CI](https://github.com/N-T-Raghava/NatQuery/actions/workflows/ci.yml/badge.svg)](https://github.com/N-T-Raghava/NatQuery/actions/workflows/ci.yml)
6
+ [![codecov](https://codecov.io/gh/N-T-Raghava/natquery/graph/badge.svg?token=KZIEXD9ALC)](https://codecov.io/gh/N-T-Raghava/natquery)
7
+ [![Code Style: Black](https://img.shields.io/badge/code%20style-black-000000)](https://github.com/psf/black)
8
+ [![Lint: Ruff](https://img.shields.io/badge/lint-ruff-261230)](https://github.com/astral-sh/ruff)
9
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE)
10
+
11
+ Ask PostgreSQL questions in plain English. NatQuery turns the question into SQL with an LLM, then **never runs the LLM's SQL**: the SQL is parsed, checked against the caller's role, rewritten with row filters, masks and limits, regenerated, and only then executed.
12
+
13
+ - **Authentication and roles** (student / teacher / admin or your own), defined in a YAML policy with inheritance, column grants, masks, and row filters bound to the caller's identity.
14
+ - **Leak-resistant by construction**: hidden tables and columns are absent from the LLM prompt and fail to resolve in the enforcer.
15
+ - **Tamper-evident audit log** (hash-chained, optional HMAC).
16
+ - **Several schemas** in one connection (`schema.table`, `fin.*` grants) and **database row-level security** driven by the caller's identity.
17
+ - **Pluggable**: auth provider, database backend, LLM, rate limiter, session store, input guard.
18
+ - **Bounded repair loop**: if the enforcer rejects a fixable query, the LLM gets the (sanitised) reason and tries again, at most twice.
19
+
20
+ See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) for the security model and known limits.
21
+
22
+ ## Benchmark
23
+
24
+ On BIRD Mini-Dev (PostgreSQL, 500 questions) with the open `gpt-oss-120b` model, NatQuery scores **45.6% official execution accuracy** with the security layer on, at about 1.1 s per question and $0.0004 per question. Full results and limitations: [docs/BIRD_REPORT.md](docs/BIRD_REPORT.md). Reproduction: [benchmarks/bird](benchmarks/bird/README.md).
25
+
26
+ ## Security testing
27
+
28
+ On AdventureWorks with three roles, 227 hostile SQL queries (560 role-by-query runs), 40 auth/audit checks and 30 natural-language attacks produced **zero leaks**; an unprotected text-to-SQL leaked on 7 of 8 comparable attacks. Details and limitations: [docs/SECURITY_REPORT.md](docs/SECURITY_REPORT.md). Reproduction: [benchmarks/security](benchmarks/security/README.md).
29
+
30
+ ## ERP test bed
31
+
32
+ `erp/` holds a synthetic university ERP (10 schemas, 87 tables, about 368,000 rows, 10 roles, logins in SQL, row-level security) and a 40-question benchmark in three difficulty levels. It exercises multi-schema support (`db_schemas`, `schema.table`, `fin.*` grants) and database-side row-level security (`db_session_vars`). Database checks: 51 of 51; no-LLM dry run through the full pipeline: 41 of 41. Details: [erp/README.md](erp/README.md), questions: [erp/ERP_Benchmark_Questions.md](erp/ERP_Benchmark_Questions.md).
33
+
34
+ ## Install and test
35
+
36
+ ```bash
37
+ pip install -e ".[dev]"
38
+ pytest # ~850 tests, 90% coverage gate
39
+ natquery --help
40
+ ```
41
+
42
+ ## Licence
43
+
44
+ MIT. BIRD benchmark data under `benchmarks/bird/results` is CC BY-SA 4.0.
45
+
46
+ ## Quick start
47
+
48
+ ```bash
49
+ pip install natquery
50
+ natquery connect # database, schema and LLM key (kept in your workspace, never in the repo)
51
+ natquery policy init # writes an example policy.yaml and semantics.json to edit
52
+ natquery user add alice --roles student # see `natquery user add --help`
53
+ natquery # interactive shell: log in, then ask questions in English
54
+ ```
55
+
56
+ ## Repository layout
57
+
58
+ | Path | Content |
59
+ |---|---|
60
+ | `src/natquery/` | The library (auth, access control, enforcer, audit, backends, LLM, CLI) |
61
+ | `tests/` | Unit and integration tests |
62
+ | `benchmarks/bird/` | BIRD Mini-Dev accuracy and efficiency benchmark |
63
+ | `benchmarks/security/` | AdventureWorks security benchmark (hostile SQL, auth, natural-language attacks) |
64
+ | `benchmarks/benchmarker.py`, `benchmarks/results/` | Earlier v1 query-optimisation benchmark and its results |
65
+ | `erp/` | Synthetic university ERP test bed (87 tables, row-level security) and 40-question benchmark |
66
+ | `docs/` | Architecture and security model, BIRD report, security report |
67
+ | `report/` | LaTeX source of the B.Tech project report |
@@ -0,0 +1,130 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77.0", "wheel"] # >=77: SPDX license expressions
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "natquery"
7
+ dynamic = ["version"] # single source of truth: natquery/__init__.py
8
+ description = "Ask PostgreSQL questions in plain English through a secure CLI with authentication, role-based access control and tamper-evident auditing"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ authors = [
13
+ {name = "Tanmai Raghava", email = "tanmairaghava@kgpian.iitkgp.ac.in"},
14
+ {name = "Krishna Chaitanya", email = "krish89@kgpian.iitkgp.ac.in"},
15
+ {name = "Thania Joshi", email = "thaniavjoshi@kgpian.iitkgp.ac.in"},
16
+ {name = "Lokeswara Reddy", email = "lokeswarareddy2006@gmail.com"},
17
+ {name = "Manasa Vankam", email = "vankammanasa45@gmail.com"}
18
+ ]
19
+ keywords = ["nlp", "database", "postgres", "natural-language", "cli", "llm", "rbac", "security", "erp"]
20
+ classifiers = [
21
+ "Development Status :: 4 - Beta",
22
+ "Environment :: Console",
23
+ "Intended Audience :: Developers",
24
+ "Intended Audience :: System Administrators",
25
+ "Natural Language :: English",
26
+ "Operating System :: OS Independent",
27
+ "Programming Language :: Python :: 3",
28
+ "Programming Language :: Python :: 3.10",
29
+ "Programming Language :: Python :: 3.11",
30
+ "Programming Language :: Python :: 3.12",
31
+ "Programming Language :: Python :: 3.13",
32
+ "Topic :: Database",
33
+ "Topic :: Security",
34
+ "Topic :: Utilities",
35
+ ]
36
+
37
+ dependencies = [
38
+ "psycopg2-binary>=2.9.0",
39
+ # The SQL enforcer inspects sqlglot's node classes (e.g. exp.SetOperation, added in 25.34).
40
+ # Tested on 25.34 - 30.21. Widen the range only after running the full test suite on the new version.
41
+ "sqlglot>=25.34.0,<31",
42
+ "groq>=0.4.0",
43
+ "rich>=13.0.0",
44
+ "PyYAML>=6.0", # access-policy files (policy.yaml)
45
+ ]
46
+
47
+ [project.urls]
48
+ Homepage = "https://github.com/N-T-Raghava/NatQuery"
49
+ Documentation = "https://github.com/N-T-Raghava/NatQuery#readme"
50
+ Repository = "https://github.com/N-T-Raghava/NatQuery"
51
+ Issues = "https://github.com/N-T-Raghava/NatQuery/issues"
52
+ Changelog = "https://github.com/N-T-Raghava/NatQuery/blob/main/CHANGELOG.md"
53
+
54
+ [project.optional-dependencies]
55
+ dev = [
56
+ "pytest>=8.0.0",
57
+ "pytest-cov>=4.0.0",
58
+ "pytest-timeout>=2.1.0",
59
+ "hypothesis>=6.100.0",
60
+ "black==25.1.0",
61
+ "ruff==0.15.6",
62
+ "build>=1.0.0",
63
+ "twine>=4.0.0"
64
+ ]
65
+
66
+ [project.scripts]
67
+ natquery = "natquery.cli.main:main"
68
+
69
+ # Auth providers / LLM providers / DB backends are plug-ins. A separate package can register an
70
+ # auth provider by exposing an entry point in the group "natquery.auth_providers", e.g.
71
+ # [project.entry-points."natquery.auth_providers"]
72
+ # my-sso = "my_pkg.sso:create_provider"
73
+
74
+ [tool.setuptools.dynamic]
75
+ version = {attr = "natquery.__version__"}
76
+
77
+ [tool.setuptools.packages.find]
78
+ where = ["src"]
79
+ include = ["natquery*"]
80
+
81
+ [tool.setuptools.package-data]
82
+ # `natquery policy init` copies these into the user's workspace; they must ship in the wheel.
83
+ natquery = ["examples/*.yaml", "examples/*.json", "examples/*.sql"]
84
+
85
+ [tool.pytest.ini_options]
86
+ minversion = "8.0"
87
+ testpaths = ["tests"]
88
+ pythonpath = ["src", "tests"]
89
+ addopts = "-rfE --strict-markers --strict-config --cov=natquery --cov-report=term-missing:skip-covered --cov-fail-under=90"
90
+ timeout = 120
91
+ markers = [
92
+ "integration: needs a real PostgreSQL (set NATQUERY_TEST_PG_HOST/PORT/USER/PASSWORD; skipped otherwise)",
93
+ ]
94
+ filterwarnings = ["error::pytest.PytestUnraisableExceptionWarning"]
95
+
96
+ [tool.coverage.run]
97
+ source = ["natquery"]
98
+ branch = true
99
+ # Nothing is omitted: every module is covered by the unit suite. Integration tests add more
100
+ # when a database is available but are not needed to reach the gate.
101
+
102
+ [tool.coverage.report]
103
+ show_missing = true
104
+ exclude_lines = [
105
+ "pragma: no cover",
106
+ "if __name__ == .__main__.:",
107
+ "raise NotImplementedError",
108
+ "@(abc\\.)?abstractmethod",
109
+ "\\.\\.\\.$",
110
+ ]
111
+
112
+ [tool.black]
113
+ line-length = 88
114
+ target-version = ["py310"]
115
+
116
+ [tool.ruff]
117
+ line-length = 88
118
+ target-version = "py310"
119
+
120
+ [tool.ruff.lint]
121
+ select = ["E4", "E7", "E9", "F", "I", "B", "UP", "SIM"]
122
+ ignore = ["B008", "SIM108", "UP007"]
123
+
124
+ [tool.ruff.lint.per-file-ignores]
125
+ "tests/**" = ["B011", "SIM117", "E741"]
126
+ # Synthetic-data generators and benchmark runners: they are scripts, not library code. Style rules are
127
+ # relaxed here because tidying them (unused values, loop counters) risks changing the seeded data
128
+ # and the benchmark corpora that the published results depend on.
129
+ "erp/**" = ["B007", "B905", "E402", "E731", "F403", "F405", "F841", "SIM113", "SIM115", "UP031"]
130
+ "benchmarks/**" = ["B007", "B905", "E741"]
@@ -0,0 +1,17 @@
1
+ """NatQuery - ask your database questions in plain English, with role-based access control.
2
+
3
+ from natquery import NatQuery
4
+ nq = NatQuery.from_workspace()
5
+ session = nq.login({"username": "...", "password": "..."})
6
+ response = nq.ask(session, "how many students are in CSE?")
7
+ """
8
+
9
+ __version__ = "2.0.0"
10
+
11
+
12
+ def __getattr__(name): # lazy: importing `natquery` must stay cheap
13
+ if name == "NatQuery":
14
+ from natquery.app import NatQueryApp
15
+
16
+ return NatQueryApp
17
+ raise AttributeError(name)