db-agent-kit 0.2.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 (89) hide show
  1. db_agent_kit-0.2.0/.github/workflows/ci.yml +25 -0
  2. db_agent_kit-0.2.0/.github/workflows/release.yml +87 -0
  3. db_agent_kit-0.2.0/.gitignore +10 -0
  4. db_agent_kit-0.2.0/CHANGELOG.md +30 -0
  5. db_agent_kit-0.2.0/CONTRIBUTING.md +17 -0
  6. db_agent_kit-0.2.0/LICENSE +201 -0
  7. db_agent_kit-0.2.0/Makefile +31 -0
  8. db_agent_kit-0.2.0/PKG-INFO +192 -0
  9. db_agent_kit-0.2.0/README.md +152 -0
  10. db_agent_kit-0.2.0/docker-compose.edge.yml +18 -0
  11. db_agent_kit-0.2.0/docker-compose.yml +28 -0
  12. db_agent_kit-0.2.0/docs/adding-an-engine.md +24 -0
  13. db_agent_kit-0.2.0/docs/databricks-health.md +59 -0
  14. db_agent_kit-0.2.0/docs/demo.md +38 -0
  15. db_agent_kit-0.2.0/docs/images/summary.png +0 -0
  16. db_agent_kit-0.2.0/docs/permissions.md +89 -0
  17. db_agent_kit-0.2.0/docs/risk-rules.md +49 -0
  18. db_agent_kit-0.2.0/docs/ssrs-inventory.md +97 -0
  19. db_agent_kit-0.2.0/docs/testing.md +80 -0
  20. db_agent_kit-0.2.0/examples/README.md +27 -0
  21. db_agent_kit-0.2.0/examples/generate_examples.py +246 -0
  22. db_agent_kit-0.2.0/examples/rdl/Finance/QuarterlyTaxSummary.rdl +2 -0
  23. db_agent_kit-0.2.0/examples/rdl/HR/EmployeeDirectory.rdl +5 -0
  24. db_agent_kit-0.2.0/examples/rdl/Inventory/BillOfMaterials.rdl +2 -0
  25. db_agent_kit-0.2.0/examples/rdl/Inventory/LegacyInventory.rdl +2 -0
  26. db_agent_kit-0.2.0/examples/rdl/Inventory/ProductCatalog.rdl +2 -0
  27. db_agent_kit-0.2.0/examples/rdl/Purchasing/VendorSpend.rdl +2 -0
  28. db_agent_kit-0.2.0/examples/rdl/Sales/CustomerOrders.rdl +2 -0
  29. db_agent_kit-0.2.0/examples/rdl/Sales/MonthlyCommissions.rdl +2 -0
  30. db_agent_kit-0.2.0/examples/rdl/Sales/OldPriceList.rdl +2 -0
  31. db_agent_kit-0.2.0/examples/rdl/Sales/OrderDetails.rdl +2 -0
  32. db_agent_kit-0.2.0/examples/rdl/Sales/SalesByTerritory.rdl +2 -0
  33. db_agent_kit-0.2.0/examples/rdl/Sales/TopProducts.rdl +2 -0
  34. db_agent_kit-0.2.0/examples/rdl/subscriptions.csv +2 -0
  35. db_agent_kit-0.2.0/examples/usage.csv +658 -0
  36. db_agent_kit-0.2.0/examples/usage_60days.csv +171 -0
  37. db_agent_kit-0.2.0/pyproject.toml +62 -0
  38. db_agent_kit-0.2.0/scripts/restore_adventureworks.py +64 -0
  39. db_agent_kit-0.2.0/scripts/scale_test.py +63 -0
  40. db_agent_kit-0.2.0/scripts/seed_risky_objects.py +91 -0
  41. db_agent_kit-0.2.0/src/db_agent/__init__.py +3 -0
  42. db_agent_kit-0.2.0/src/db_agent/cli.py +32 -0
  43. db_agent_kit-0.2.0/src/db_agent/engines/__init__.py +36 -0
  44. db_agent_kit-0.2.0/src/db_agent/engines/databricks/__init__.py +1 -0
  45. db_agent_kit-0.2.0/src/db_agent/engines/databricks/checks.py +221 -0
  46. db_agent_kit-0.2.0/src/db_agent/engines/databricks/cli.py +61 -0
  47. db_agent_kit-0.2.0/src/db_agent/engines/databricks/client.py +86 -0
  48. db_agent_kit-0.2.0/src/db_agent/engines/databricks/cost.py +96 -0
  49. db_agent_kit-0.2.0/src/db_agent/engines/databricks/health.py +156 -0
  50. db_agent_kit-0.2.0/src/db_agent/engines/databricks/model.py +29 -0
  51. db_agent_kit-0.2.0/src/db_agent/engines/databricks/queries.py +98 -0
  52. db_agent_kit-0.2.0/src/db_agent/engines/databricks/render.py +78 -0
  53. db_agent_kit-0.2.0/src/db_agent/engines/databricks/runtimes.py +58 -0
  54. db_agent_kit-0.2.0/src/db_agent/engines/databricks/sqlguard.py +80 -0
  55. db_agent_kit-0.2.0/src/db_agent/engines/sqlserver/__init__.py +11 -0
  56. db_agent_kit-0.2.0/src/db_agent/engines/sqlserver/classify.py +102 -0
  57. db_agent_kit-0.2.0/src/db_agent/engines/sqlserver/cli.py +265 -0
  58. db_agent_kit-0.2.0/src/db_agent/engines/sqlserver/data/classification.yaml +29 -0
  59. db_agent_kit-0.2.0/src/db_agent/engines/sqlserver/db.py +183 -0
  60. db_agent_kit-0.2.0/src/db_agent/engines/sqlserver/guard.py +190 -0
  61. db_agent_kit-0.2.0/src/db_agent/engines/sqlserver/inventory.py +324 -0
  62. db_agent_kit-0.2.0/src/db_agent/engines/sqlserver/outputs.py +299 -0
  63. db_agent_kit-0.2.0/src/db_agent/engines/sqlserver/rdl.py +269 -0
  64. db_agent_kit-0.2.0/src/db_agent/engines/sqlserver/report.py +120 -0
  65. db_agent_kit-0.2.0/src/db_agent/engines/sqlserver/risks.py +184 -0
  66. db_agent_kit-0.2.0/src/db_agent/engines/sqlserver/rules.py +141 -0
  67. db_agent_kit-0.2.0/src/db_agent/engines/sqlserver/sqlrefs.py +103 -0
  68. db_agent_kit-0.2.0/src/db_agent/engines/sqlserver/ssrs.py +230 -0
  69. db_agent_kit-0.2.0/src/db_agent/engines/sqlserver/templates/summary.html.j2 +142 -0
  70. db_agent_kit-0.2.0/src/db_agent/engines/sqlserver/usage.py +127 -0
  71. db_agent_kit-0.2.0/src/db_agent/engines/sqlserver/validate.py +238 -0
  72. db_agent_kit-0.2.0/tests/azure/test_azure_sql_db.py +45 -0
  73. db_agent_kit-0.2.0/tests/conftest.py +71 -0
  74. db_agent_kit-0.2.0/tests/databricks/dbx_fakes.py +66 -0
  75. db_agent_kit-0.2.0/tests/databricks/test_databricks_health.py +151 -0
  76. db_agent_kit-0.2.0/tests/databricks/test_databricks_unit.py +106 -0
  77. db_agent_kit-0.2.0/tests/integration/__init__.py +0 -0
  78. db_agent_kit-0.2.0/tests/integration/conftest.py +64 -0
  79. db_agent_kit-0.2.0/tests/integration/test_live.py +190 -0
  80. db_agent_kit-0.2.0/tests/seeded/test_seeded_risks.py +48 -0
  81. db_agent_kit-0.2.0/tests/test_architecture.py +39 -0
  82. db_agent_kit-0.2.0/tests/test_classify_usage.py +78 -0
  83. db_agent_kit-0.2.0/tests/test_cli_and_secrets.py +114 -0
  84. db_agent_kit-0.2.0/tests/test_guard.py +82 -0
  85. db_agent_kit-0.2.0/tests/test_packaging.py +14 -0
  86. db_agent_kit-0.2.0/tests/test_rdl_and_refs.py +81 -0
  87. db_agent_kit-0.2.0/tests/test_risks.py +51 -0
  88. db_agent_kit-0.2.0/tests/test_root_cli.py +34 -0
  89. db_agent_kit-0.2.0/tests/test_validate_pure.py +67 -0
@@ -0,0 +1,25 @@
1
+ name: ci
2
+ # Public repo, untrusted PRs: pull_request only (never pull_request_target), no secrets, no databases, hosted runners only.
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches: [main]
7
+ permissions:
8
+ contents: read
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-24.04
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ python: ["3.11", "3.12", "3.13"]
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ with:
19
+ persist-credentials: false
20
+ - uses: actions/setup-python@v5
21
+ with:
22
+ python-version: ${{ matrix.python }}
23
+ - run: pip install -e ".[dev]"
24
+ - run: pytest -q --ignore=tests/integration
25
+ - run: db-agent engines
@@ -0,0 +1,87 @@
1
+ name: release
2
+ # Publishes to PyPI with Trusted Publishing (OIDC): no API token is stored anywhere.
3
+ # One-time setup on pypi.org: Your projects > Publishing > add a (pending) publisher with project name db-agent-kit,
4
+ # owner/repo = db-agent/db-agent-kit, workflow = release.yml, environment = pypi
5
+ # For the TestPyPI dry run, do the same on test.pypi.org with environment = testpypi.
6
+ on:
7
+ push:
8
+ tags: ["v*"]
9
+ workflow_dispatch:
10
+ inputs:
11
+ target:
12
+ description: "Where to publish"
13
+ type: choice
14
+ options: [testpypi, pypi]
15
+ default: testpypi
16
+
17
+ permissions:
18
+ contents: read
19
+
20
+ jobs:
21
+ build:
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+ with:
26
+ persist-credentials: false
27
+ - uses: actions/setup-python@v5
28
+ with:
29
+ python-version: "3.12"
30
+ - run: pip install build twine
31
+ - name: Tag must match the package version
32
+ if: startsWith(github.ref, 'refs/tags/v')
33
+ run: |
34
+ INIT=$(python -c "import re,pathlib;print(re.search(r'__version__ = \"(.+?)\"', pathlib.Path('src/db_agent/__init__.py').read_text()).group(1))")
35
+ TOML=$(python -c "import tomllib;print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
36
+ [ "$INIT" = "$TOML" ] || { echo "__init__ $INIT != pyproject $TOML"; exit 1; }
37
+ [ "v$TOML" = "${GITHUB_REF_NAME}" ] || { echo "tag ${GITHUB_REF_NAME} != version v$TOML"; exit 1; }
38
+ - run: python -m build
39
+ - run: twine check --strict dist/*
40
+ - name: Only db_agent is installed, and no keys or output files are shipped
41
+ run: |
42
+ unzip -l dist/*.whl | awk '{print $4}' | grep -E '^[a-z_]+/' | cut -d/ -f1 | sort -u | grep -vE '^(db_agent|db_agent_kit-.*\.dist-info)$' && { echo "unexpected top-level in wheel"; exit 1; } || true
43
+ ! (unzip -l dist/*.whl; tar tzf dist/*.tar.gz) | grep -E '\.(pem|env|xlsx)$|(^|/)\.env|-output/'
44
+ - name: Install the wheel in a clean venv and run it
45
+ run: |
46
+ python -m venv /tmp/smoke && /tmp/smoke/bin/pip install dist/*.whl
47
+ /tmp/smoke/bin/db-agent engines
48
+ /tmp/smoke/bin/db-agent sqlserver --help
49
+ /tmp/smoke/bin/db-agent databricks --help
50
+ - uses: actions/upload-artifact@v4
51
+ with:
52
+ name: dist
53
+ path: dist/
54
+
55
+ publish-testpypi:
56
+ if: github.event_name == 'workflow_dispatch' && inputs.target == 'testpypi'
57
+ needs: build
58
+ runs-on: ubuntu-latest
59
+ environment:
60
+ name: testpypi
61
+ url: https://test.pypi.org/p/db-agent-kit
62
+ permissions:
63
+ id-token: write
64
+ steps:
65
+ - uses: actions/download-artifact@v4
66
+ with:
67
+ name: dist
68
+ path: dist/
69
+ - uses: pypa/gh-action-pypi-publish@release/v1
70
+ with:
71
+ repository-url: https://test.pypi.org/legacy/
72
+
73
+ publish-pypi:
74
+ if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && inputs.target == 'pypi')
75
+ needs: build
76
+ runs-on: ubuntu-latest
77
+ environment:
78
+ name: pypi
79
+ url: https://pypi.org/p/db-agent-kit
80
+ permissions:
81
+ id-token: write
82
+ steps:
83
+ - uses: actions/download-artifact@v4
84
+ with:
85
+ name: dist
86
+ path: dist/
87
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,10 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ db-agent-sqlserver-output/
5
+ private_out/
6
+ .pytest_cache/
7
+ dist/
8
+ build/
9
+ *.egg-info/
10
+ /data/
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0 (2026-11-07)
4
+
5
+ First release.
6
+
7
+ ### Added
8
+
9
+ - One `db-agent` command with a command group per engine: `db-agent <engine> <verb>`. `db-agent engines` lists the engines and `db-agent version` prints the version.
10
+ - `sqlserver` engine, for SQL Server 2016/2017 upgrades and SSRS to Power BI moves:
11
+ - `inventory`: version, edition, databases, tables, row counts from metadata, views, procedures, linked servers and Agent jobs, with upgrade risks and a link to the Microsoft page for each.
12
+ - `ssrs`: every report with its data sources, datasets, parameters, subreports, subscriptions and usage. Each report is classified as move, review or retire, with the reason. It reads the ReportServer database or a folder of `.rdl` files.
13
+ - `validate`: runs each "move" report's queries on the old and new server and compares row counts and totals.
14
+ - `report`: combines the outputs into `summary.html` and an Excel workbook. Output formats are md, json, xlsx and html.
15
+ - Windows authentication through ODBC (`--driver odbc`, optional `odbc` extra).
16
+ - `databricks` engine, `health` command: runtimes past or near end of support, legacy dependencies (Hive metastore tables, DBFS mount events, init scripts on DBFS, clusters without a Unity Catalog access mode), DBU spend by month at list price, and spend waste (scheduled jobs on all-purpose clusters, clusters without auto-termination, idle SQL warehouses, untagged spend).
17
+ - Read-only guards:
18
+ - SQL Server: one statement only, a `SELECT` or `WITH ... SELECT`, or a stored procedure you name with `--allow-exec`. Anything else is refused, including `SELECT INTO`, `OPENROWSET` and linked-server names. A test checks that no module except `db.py` touches a driver.
19
+ - Databricks: REST list and get calls only. SQL is limited to `SELECT`/`WITH` and `SHOW ... IN hive_metastore`. A test checks that only `client.py` imports the SDK.
20
+ - Permissions for a least-privilege SQL Server login are in `docs/permissions.md`.
21
+ - Sample data in `examples/`: 12 sample reports and a synthetic usage log, for a demo that needs no database (`make demo-files`).
22
+
23
+ ### Changed
24
+
25
+ - The project started as the single-engine `db-agent-sqlserver` package. It is now the `db_agent` package with engines under `db_agent.engines`.
26
+ - The repository is named `db-agent-kit`.
27
+
28
+ ### Testing
29
+
30
+ What was tested, and what was not, is in `docs/testing.md` and `docs/databricks-health.md`. The Databricks engine was live-tested on one small AWS workspace only.
@@ -0,0 +1,17 @@
1
+ # Contributing
2
+
3
+ ```bash
4
+ python3 -m venv .venv && .venv/bin/pip install -e ".[dev]"
5
+ make test # no database needed
6
+ ```
7
+
8
+ ## Release
9
+
10
+ 1. Bump the version in **both** `pyproject.toml` and `src/db_agent/__init__.py`, and date the entry in `CHANGELOG.md`.
11
+ 2. Merge to `main`, then tag `vX.Y.Z` on `main`. The `release` workflow builds, runs `twine check --strict`, checks the tag
12
+ equals both version strings, installs the wheel in a clean venv, and publishes to PyPI with Trusted Publishing (no tokens).
13
+ Use the manual `testpypi` run first for a dry run.
14
+ 3. One time: on pypi.org add a (pending) publisher for project `db-agent-kit`, repo `db-agent/db-agent-kit`, workflow `release.yml`, environment `pypi`
15
+ (and the same on test.pypi.org with environment `testpypi`). Create the matching environments in the GitHub repo settings.
16
+
17
+ Never publish by hand.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,31 @@
1
+ # make demo-files no database needed: reads the sample reports and the synthetic usage log
2
+ # make demo full demo: needs the containers (see README), runs all four commands
3
+ PY ?= .venv/bin/python
4
+ CLI = $(PY) -m db_agent.cli sqlserver
5
+ OUT ?= db-agent-sqlserver-output
6
+ export DBAGENT_SQL_PASSWORD ?= DbAgent_Demo_2017!
7
+ export DBAGENT_SOURCE_PASSWORD ?= DbAgent_Demo_2017!
8
+ export DBAGENT_TARGET_PASSWORD ?= DbAgent_Demo_2017!
9
+ DB = AdventureWorks2017
10
+
11
+ test:
12
+ $(PY) -m pytest -q --ignore=tests/integration
13
+
14
+ test-live:
15
+ DBAGENT_TEST_SERVER=localhost $(PY) -m pytest -q
16
+
17
+ examples:
18
+ $(PY) examples/generate_examples.py
19
+
20
+ demo-files: examples
21
+ $(CLI) ssrs --rdl-folder examples/rdl --usage-csv examples/usage.csv --out $(OUT)
22
+ open $(OUT)/summary.html
23
+
24
+ demo: examples
25
+ $(CLI) inventory --server localhost --port 14331 --user sa --no-encrypt --databases $(DB) --out $(OUT)
26
+ $(CLI) ssrs --rdl-folder examples/rdl --usage-csv examples/usage.csv --data-database $(DB) --server localhost --port 14331 --user sa --no-encrypt --out $(OUT)
27
+ $(CLI) validate --source "server=localhost,port=14331,database=$(DB),user=sa,encrypt=no" --target "server=localhost,port=14332,database=$(DB),user=sa,encrypt=no" --reports $(OUT)/reports.csv --allow-exec --out $(OUT)
28
+ $(CLI) report --out $(OUT)
29
+ open $(OUT)/summary.html
30
+
31
+ .PHONY: test test-live examples demo-files demo
@@ -0,0 +1,192 @@
1
+ Metadata-Version: 2.5
2
+ Name: db-agent-kit
3
+ Version: 0.2.0
4
+ Summary: Read-only DBA toolkit CLI: SQL Server 2016/2017 upgrade and SSRS to Power BI inventory, Databricks workspace health and DBU cost checks.
5
+ Project-URL: Homepage, https://github.com/db-agent/db-agent-kit
6
+ Project-URL: Documentation, https://github.com/db-agent/db-agent-kit/tree/main/docs
7
+ Project-URL: Issues, https://github.com/db-agent/db-agent-kit/issues
8
+ Project-URL: Text-to-SQL agent, https://github.com/db-agent/db-agent
9
+ Project-URL: Fixed-price help, https://becloudready.com/sql-server
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: azure-sql,cli,database-inventory,database-migration,databricks,dba,dbu-cost,end-of-life,migration-assessment,power-bi,sql-server,sql-server-upgrade,ssrs,unity-catalog
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Information Technology
16
+ Classifier: Intended Audience :: System Administrators
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Database
23
+ Classifier: Topic :: System :: Systems Administration
24
+ Classifier: Topic :: Utilities
25
+ Requires-Python: >=3.11
26
+ Requires-Dist: databricks-sdk>=0.40
27
+ Requires-Dist: jinja2>=3.1
28
+ Requires-Dist: lxml>=5
29
+ Requires-Dist: openpyxl>=3.1
30
+ Requires-Dist: pandas>=2.2
31
+ Requires-Dist: pymssql>=2.3
32
+ Requires-Dist: pyyaml>=6
33
+ Requires-Dist: sqlglot>=25
34
+ Requires-Dist: typer>=0.12
35
+ Provides-Extra: dev
36
+ Requires-Dist: pytest>=8; extra == 'dev'
37
+ Provides-Extra: odbc
38
+ Requires-Dist: pyodbc>=5; extra == 'odbc'
39
+ Description-Content-Type: text/markdown
40
+
41
+ # db-agent CLI: read-only DBA toolkit for SQL Server, SSRS and Databricks
42
+
43
+ Check a database before you upgrade, migrate or pay for another year of it. db-agent only reads, and writes a report you can hand to a manager: SQL Server 2016/2017 upgrade risks, an SSRS to Power BI report inventory, and Databricks workspace health with DBU spend. One command per engine. Nothing is changed on any server.
44
+
45
+ Looking for the text-to-SQL agent? See [db-agent/db-agent](https://github.com/db-agent/db-agent).
46
+
47
+ ```
48
+ db-agent <engine> <verb>
49
+ db-agent engines # what is implemented and what is planned
50
+ ```
51
+
52
+ | Engine | Status | Verbs |
53
+ |---|---|---|
54
+ | `sqlserver` | available | `inventory`, `ssrs`, `validate`, `report` |
55
+ | `databricks` | available; live-tested on one small AWS workspace only, see the docs | `health` ([docs](https://github.com/db-agent/db-agent-kit/blob/main/docs/databricks-health.md)) |
56
+
57
+ Each engine is described below. To add one, see [docs/adding-an-engine.md](https://github.com/db-agent/db-agent-kit/blob/main/docs/adding-an-engine.md).
58
+
59
+ ## db-agent sqlserver: inventory SQL Server and SSRS reports before you upgrade or move to Power BI
60
+
61
+ SQL Server 2016 reached end of support on July 14, 2026. SQL Server 2017 follows on October 12, 2027.
62
+ If you run SSRS (SQL Server Reporting Services) on either, you have two jobs: upgrade the database
63
+ server, and decide what happens to every report. This command line tool does the **SSRS migration
64
+ inventory** and the upgrade check, **read-only**. It lists your databases and reports, flags what will
65
+ break, sorts each report into **move**, **review** or **retire**, checks results after a move, and writes
66
+ a report you can hand to a manager or a client. It is the first step of an **SSRS to Power BI** move.
67
+
68
+ *Part of the [db-agent](https://github.com/db-agent) project.* Apache-2.0.
69
+
70
+ ![Sample summary report](https://raw.githubusercontent.com/db-agent/db-agent-kit/main/docs/images/summary.png)
71
+
72
+ ## What it does
73
+
74
+ | Command | What you get |
75
+ |---|---|
76
+ | `sqlserver inventory` | Version, edition, databases, tables, row counts (from metadata), views, procedures with code, linked servers, Agent jobs. **Upgrade risks**, each with a link to the Microsoft page it comes from. |
77
+ | `sqlserver ssrs` | Every report: data sources, datasets, tables and procedures used, parameters, subreports, custom code, subscriptions, usage. Each report is **move**, **review** or **retire** with the reason. |
78
+ | `sqlserver validate` | Runs each "move" report's queries on the old and new server and compares row counts and totals. |
79
+ | `sqlserver report` | One printable `summary.html` and one Excel workbook with all of it. |
80
+
81
+ ## Install
82
+
83
+ ```bash
84
+ pip install db-agent-kit # after the first PyPI release
85
+ ```
86
+
87
+ From source (Python 3.11 or newer):
88
+
89
+ ```bash
90
+ git clone https://github.com/db-agent/db-agent-kit && cd db-agent-kit
91
+ python3 -m venv .venv && .venv/bin/pip install -e .
92
+ ```
93
+
94
+ A Docker image and a Windows single-file `.exe` do not exist yet.
95
+
96
+ ## 5-minute demo (no database needed)
97
+
98
+ Run this from the source checkout (see Install):
99
+
100
+ ```bash
101
+ make demo-files
102
+ ```
103
+
104
+ This reads 12 sample reports and a synthetic usage log (`examples/`, clearly labelled sample data) and
105
+ opens `summary.html`. You will see 5 move, 5 review and 2 retire, each with a reason.
106
+
107
+ To also see `inventory` and `validate`, start two SQL Server containers, restore the AdventureWorks
108
+ sample database and run `make demo`. See [docs/demo.md](https://github.com/db-agent/db-agent-kit/blob/main/docs/demo.md).
109
+
110
+ ## Use it
111
+
112
+ Run it as `db-agent sqlserver <command>`.
113
+
114
+ ```bash
115
+ db-agent sqlserver inventory --server sql01 --user dbagent_reader # password: env DBAGENT_SQL_PASSWORD or a prompt
116
+ db-agent sqlserver ssrs --reportserver-db ReportServer --server sql01 --user dbagent_reader
117
+ db-agent sqlserver ssrs --rdl-folder ./reports --usage-csv executionlog.csv # no server access needed
118
+ db-agent sqlserver validate --source "server=old,database=Sales,user=u" --target "server=new,database=Sales,user=u" --reports db-agent-sqlserver-output/reports.csv
119
+ db-agent sqlserver report
120
+ ```
121
+
122
+ Output goes to `./db-agent-sqlserver-output` (change with `--out`). Windows authentication needs `--driver odbc`,
123
+ `pip install ".[odbc]"` and a Microsoft ODBC driver for SQL Server. The tool finds driver 18, 17 or 13 on its own; set
124
+ `DBAGENT_ODBC_DRIVER` to force one. It was tested with driver 17 and a local Windows account (NTLM). Domain (Kerberos)
125
+ logins and Microsoft Entra ID were not tested.
126
+
127
+ ## What your DBA needs to grant
128
+
129
+ A dedicated login with read access to metadata and the ReportServer catalog. Nothing that can write.
130
+ The exact T-SQL script is in [docs/permissions.md](https://github.com/db-agent/db-agent-kit/blob/main/docs/permissions.md).
131
+
132
+ ## Sample output
133
+
134
+ `reports.csv`, one row per report (a few of the columns; run counts move with the date you run it):
135
+
136
+ | path | classification | runs_365 | last_run | reasons |
137
+ |---|---|---|---|---|
138
+ | /Inventory/BillOfMaterials | move | 41 | 2026-11-03 | Plain report, no hard-to-move features |
139
+ | /HR/EmployeeDirectory | review | 12 | 2026-11-02 | Custom code block (3 lines) |
140
+ | /Purchasing/VendorSpend | review | 50 | 2026-11-04 | Dataset SQL could not be fully parsed (Spend); table list is a guess |
141
+ | /Inventory/LegacyInventory | retire | 0 | | No runs in the last 365 days (log covers 522 days) |
142
+
143
+ ## What it does not do
144
+
145
+ - It does **not convert reports.** It tells you what to move and what is hard. A layout hint says which reports look like Power BI paginated reports and which look like an interactive rebuild. It is a hint only.
146
+ - It does **not read business data** during `inventory` or `ssrs`. Row counts come from system views.
147
+ - `validate` is the one command that runs report queries. It keeps **only row counts and numeric totals**, never row values, and only on a login you choose to give read access to.
148
+ - It does **not change anything** on any server, and sends nothing over the network except to the SQL Servers you name.
149
+
150
+ ## FAQ
151
+
152
+ **Is it safe?** Every statement goes through one guard that allows a single `SELECT` (or, with `--allow-exec`, a stored procedure you named). `SELECT ... INTO`, `OPENROWSET`, linked servers and anything it cannot parse are refused. Tests check that no command can bypass it. The login's permissions are the real boundary: give it only what [docs/permissions.md](https://github.com/db-agent/db-agent-kit/blob/main/docs/permissions.md) lists.
153
+
154
+ **What access does it need?** See above. For `ssrs` without database access, export the `.rdl` files and the execution log and run it on a laptop.
155
+
156
+ **Does it work with Azure SQL?** It reads Azure SQL Database and Managed Instance for `inventory` and flags what would not work there. Tested against one Azure SQL Database (AdventureWorksLT); Managed Instance is not tested.
157
+
158
+ **What about Power BI paginated reports?** Reports are classified by what is hard to move, not converted. The hint column says which look paginated. Check Microsoft's current paginated report limits for your reports.
159
+
160
+ **Why are no reports marked retire?** SSRS keeps its usage log for 60 days by default. A report that runs once a year looks unused in a 60-day log. The kit only calls a report retire when the log covers 365 days, and says so. See [docs/ssrs-inventory.md](https://github.com/db-agent/db-agent-kit/blob/main/docs/ssrs-inventory.md).
161
+
162
+ **Where does my data go?** Nowhere. Everything is written to a local folder. Object code (`modules.json`) can contain secrets: skip it with `--no-code`.
163
+
164
+ ## db-agent databricks: workspace health and DBU spend
165
+
166
+ ```bash
167
+ databricks auth login --host https://<workspace>.cloud.databricks.com
168
+ db-agent databricks health # uses a SQL warehouse that is already running
169
+ db-agent databricks health --profile <name> --warehouse-id <id> --out ./out
170
+ db-agent databricks health --no-sql # REST API checks only, no warehouse needed
171
+ ```
172
+
173
+ It reads the REST API and system tables and changes nothing. It checks:
174
+
175
+ - Clusters and job clusters on runtimes past end of support, or within 180 days of it (`--eos-warning-days`). In the built-in table, 13.3 LTS ended on 2026-08-22 and 14.3 LTS ends on 2027-02-01.
176
+ - Legacy dependencies: Hive metastore tables, DBFS mount events, init scripts stored on DBFS, and clusters without a Unity Catalog access mode.
177
+ - DBU spend by month at list price, split into usage and price change, with a note when the SKU tier changes.
178
+ - Spend waste: scheduled jobs on all-purpose clusters, clusters with auto-termination off, SQL warehouses billed with no queries or with auto-stop off, and spend with no tags.
179
+
180
+ Live-tested on one small AWS workspace only. See [docs/databricks-health.md](https://github.com/db-agent/db-agent-kit/blob/main/docs/databricks-health.md) for options, access needed and limits.
181
+
182
+ ## Status
183
+
184
+ Version 0.2.0. What was tested is listed in [docs/testing.md](https://github.com/db-agent/db-agent-kit/blob/main/docs/testing.md):
185
+
186
+ - `sqlserver`: real SQL Server 2017 and 2022 (Linux, Docker), real SQL Server 2016 SP3 with a real SSRS 2016 server (Windows VM), and `inventory` on one Azure SQL Database (AdventureWorksLT). ODBC with Windows authentication was tested with a local account.
187
+ - `databricks`: one small AWS workspace. See [docs/databricks-health.md](https://github.com/db-agent/db-agent-kit/blob/main/docs/databricks-health.md).
188
+ - Not tested: SSRS 2017 and later, Power BI Report Server, domain (Kerberos) authentication, Entra ID, Azure SQL Managed Instance.
189
+
190
+ [Upgrade risk rules](https://github.com/db-agent/db-agent-kit/blob/main/docs/risk-rules.md) · [SSRS inventory](https://github.com/db-agent/db-agent-kit/blob/main/docs/ssrs-inventory.md) · [Permissions](https://github.com/db-agent/db-agent-kit/blob/main/docs/permissions.md) · [Examples](https://github.com/db-agent/db-agent-kit/blob/main/examples/README.md)
191
+
192
+ Need the upgrade and report move done for you at a fixed price? [becloudready.com/sql-server](https://becloudready.com/sql-server)