relational-schema-analyzer 0.1.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 (87) hide show
  1. relational_schema_analyzer-0.1.0/.github/workflows/ci.yml +39 -0
  2. relational_schema_analyzer-0.1.0/.github/workflows/integration.yml +66 -0
  3. relational_schema_analyzer-0.1.0/.gitignore +21 -0
  4. relational_schema_analyzer-0.1.0/LICENSE +174 -0
  5. relational_schema_analyzer-0.1.0/PKG-INFO +139 -0
  6. relational_schema_analyzer-0.1.0/README.md +82 -0
  7. relational_schema_analyzer-0.1.0/docs/DESIGN.md +416 -0
  8. relational_schema_analyzer-0.1.0/docs/IMPLEMENTATION-PLAN.md +268 -0
  9. relational_schema_analyzer-0.1.0/docs/tool-contract/v1/README.md +37 -0
  10. relational_schema_analyzer-0.1.0/docs/tool-contract/v1/examples/request.analyze.json +30 -0
  11. relational_schema_analyzer-0.1.0/docs/tool-contract/v1/examples/response.analyze.json +29 -0
  12. relational_schema_analyzer-0.1.0/docs/tool-contract/v1/request.schema.json +256 -0
  13. relational_schema_analyzer-0.1.0/docs/tool-contract/v1/response.schema.json +867 -0
  14. relational_schema_analyzer-0.1.0/pyproject.toml +66 -0
  15. relational_schema_analyzer-0.1.0/relational_schema_analyzer/__init__.py +89 -0
  16. relational_schema_analyzer-0.1.0/relational_schema_analyzer/analyzer.py +118 -0
  17. relational_schema_analyzer-0.1.0/relational_schema_analyzer/baseline.py +339 -0
  18. relational_schema_analyzer-0.1.0/relational_schema_analyzer/cli.py +155 -0
  19. relational_schema_analyzer-0.1.0/relational_schema_analyzer/conceptual.py +61 -0
  20. relational_schema_analyzer-0.1.0/relational_schema_analyzer/connectors/__init__.py +36 -0
  21. relational_schema_analyzer-0.1.0/relational_schema_analyzer/connectors/base.py +221 -0
  22. relational_schema_analyzer-0.1.0/relational_schema_analyzer/connectors/csv_source.py +366 -0
  23. relational_schema_analyzer-0.1.0/relational_schema_analyzer/connectors/databricks_source.py +287 -0
  24. relational_schema_analyzer-0.1.0/relational_schema_analyzer/connectors/duckdb_source.py +279 -0
  25. relational_schema_analyzer-0.1.0/relational_schema_analyzer/connectors/mssql.py +560 -0
  26. relational_schema_analyzer-0.1.0/relational_schema_analyzer/connectors/mysql.py +503 -0
  27. relational_schema_analyzer-0.1.0/relational_schema_analyzer/connectors/postgres.py +512 -0
  28. relational_schema_analyzer-0.1.0/relational_schema_analyzer/connectors/session.py +98 -0
  29. relational_schema_analyzer-0.1.0/relational_schema_analyzer/connectors/snowflake.py +630 -0
  30. relational_schema_analyzer-0.1.0/relational_schema_analyzer/defaults.py +15 -0
  31. relational_schema_analyzer-0.1.0/relational_schema_analyzer/dump_reader.py +69 -0
  32. relational_schema_analyzer-0.1.0/relational_schema_analyzer/exports.py +24 -0
  33. relational_schema_analyzer-0.1.0/relational_schema_analyzer/fk_inference.py +1353 -0
  34. relational_schema_analyzer-0.1.0/relational_schema_analyzer/heuristics.py +43 -0
  35. relational_schema_analyzer-0.1.0/relational_schema_analyzer/log.py +52 -0
  36. relational_schema_analyzer-0.1.0/relational_schema_analyzer/mapping.py +59 -0
  37. relational_schema_analyzer-0.1.0/relational_schema_analyzer/mcp_server.py +218 -0
  38. relational_schema_analyzer-0.1.0/relational_schema_analyzer/metadata.py +85 -0
  39. relational_schema_analyzer-0.1.0/relational_schema_analyzer/naming.py +82 -0
  40. relational_schema_analyzer-0.1.0/relational_schema_analyzer/owl_export.py +377 -0
  41. relational_schema_analyzer-0.1.0/relational_schema_analyzer/providers/__init__.py +82 -0
  42. relational_schema_analyzer-0.1.0/relational_schema_analyzer/providers/anthropic_provider.py +42 -0
  43. relational_schema_analyzer-0.1.0/relational_schema_analyzer/providers/base.py +60 -0
  44. relational_schema_analyzer-0.1.0/relational_schema_analyzer/providers/openai_provider.py +33 -0
  45. relational_schema_analyzer-0.1.0/relational_schema_analyzer/providers/openrouter_provider.py +99 -0
  46. relational_schema_analyzer-0.1.0/relational_schema_analyzer/py.typed +0 -0
  47. relational_schema_analyzer-0.1.0/relational_schema_analyzer/refine.py +231 -0
  48. relational_schema_analyzer-0.1.0/relational_schema_analyzer/schema_diff.py +106 -0
  49. relational_schema_analyzer-0.1.0/relational_schema_analyzer/tool.py +125 -0
  50. relational_schema_analyzer-0.1.0/relational_schema_analyzer/topo_sort.py +106 -0
  51. relational_schema_analyzer-0.1.0/relational_schema_analyzer/typemap.py +185 -0
  52. relational_schema_analyzer-0.1.0/relational_schema_analyzer/types.py +156 -0
  53. relational_schema_analyzer-0.1.0/tests/__init__.py +0 -0
  54. relational_schema_analyzer-0.1.0/tests/_conformance.py +113 -0
  55. relational_schema_analyzer-0.1.0/tests/conftest.py +61 -0
  56. relational_schema_analyzer-0.1.0/tests/fixtures/csv_demo/authors.csv +7 -0
  57. relational_schema_analyzer-0.1.0/tests/fixtures/csv_demo/books.csv +10 -0
  58. relational_schema_analyzer-0.1.0/tests/fixtures/csv_demo/loans.csv +9 -0
  59. relational_schema_analyzer-0.1.0/tests/fixtures/csv_demo/members.csv +6 -0
  60. relational_schema_analyzer-0.1.0/tests/fixtures/csv_demo_bundle.golden.json +367 -0
  61. relational_schema_analyzer-0.1.0/tests/integration/__init__.py +0 -0
  62. relational_schema_analyzer-0.1.0/tests/integration/conftest.py +144 -0
  63. relational_schema_analyzer-0.1.0/tests/integration/test_live_conformance.py +19 -0
  64. relational_schema_analyzer-0.1.0/tests/test_analyzer.py +124 -0
  65. relational_schema_analyzer-0.1.0/tests/test_baseline.py +192 -0
  66. relational_schema_analyzer-0.1.0/tests/test_cli.py +74 -0
  67. relational_schema_analyzer-0.1.0/tests/test_connectors_base.py +170 -0
  68. relational_schema_analyzer-0.1.0/tests/test_csv_connector.py +195 -0
  69. relational_schema_analyzer-0.1.0/tests/test_databricks_connector.py +156 -0
  70. relational_schema_analyzer-0.1.0/tests/test_duckdb_connector.py +90 -0
  71. relational_schema_analyzer-0.1.0/tests/test_exports.py +34 -0
  72. relational_schema_analyzer-0.1.0/tests/test_fk_inference.py +662 -0
  73. relational_schema_analyzer-0.1.0/tests/test_golden_csv.py +87 -0
  74. relational_schema_analyzer-0.1.0/tests/test_mcp_server.py +50 -0
  75. relational_schema_analyzer-0.1.0/tests/test_mssql_connector.py +311 -0
  76. relational_schema_analyzer-0.1.0/tests/test_mysql_connector.py +346 -0
  77. relational_schema_analyzer-0.1.0/tests/test_owl_export.py +134 -0
  78. relational_schema_analyzer-0.1.0/tests/test_physical_model.py +130 -0
  79. relational_schema_analyzer-0.1.0/tests/test_postgres_connector.py +149 -0
  80. relational_schema_analyzer-0.1.0/tests/test_providers.py +43 -0
  81. relational_schema_analyzer-0.1.0/tests/test_refine.py +122 -0
  82. relational_schema_analyzer-0.1.0/tests/test_schema_diff.py +161 -0
  83. relational_schema_analyzer-0.1.0/tests/test_snowflake_connector.py +286 -0
  84. relational_schema_analyzer-0.1.0/tests/test_snowflake_fakesnow.py +75 -0
  85. relational_schema_analyzer-0.1.0/tests/test_tool.py +89 -0
  86. relational_schema_analyzer-0.1.0/tests/test_topo_sort.py +139 -0
  87. relational_schema_analyzer-0.1.0/tests/test_types.py +151 -0
@@ -0,0 +1,39 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ lint-and-test:
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ python-version: ["3.10", "3.12"]
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - name: Set up Python ${{ matrix.python-version }}
19
+ uses: actions/setup-python@v5
20
+ with:
21
+ python-version: ${{ matrix.python-version }}
22
+
23
+ - name: Install (dev + extras under test)
24
+ run: |
25
+ python -m pip install --upgrade pip
26
+ # postgres: psycopg is imported eagerly by the PG connector module.
27
+ # csv: polars backs the CSV connector. owl: rdflib for OWL round-trip tests.
28
+ # dev pulls fakesnow + snowflake-connector-python for the always-on
29
+ # Snowflake conformance tests (embedded emulator, no cloud).
30
+ # mysql/mssql drivers are intentionally NOT installed so their
31
+ # "missing driver" paths are tested. Live-DB tests are opt-in (see
32
+ # integration.yml) and skip here because RUN_INTEGRATION is unset.
33
+ python -m pip install -e ".[dev,postgres,csv,owl,duckdb,mcp]"
34
+
35
+ - name: Ruff
36
+ run: ruff check .
37
+
38
+ - name: Pytest
39
+ run: pytest -q
@@ -0,0 +1,66 @@
1
+ name: Integration (live databases)
2
+
3
+ # Live-DB conformance against Docker service containers. Runs the opt-in
4
+ # `integration` tests (RUN_INTEGRATION=1) against real Postgres + MySQL. SQL
5
+ # Server and cloud warehouses (Snowflake/Databricks) plug in via DSN env/secrets
6
+ # using the same harness; Snowflake also has always-on embedded coverage via
7
+ # fakesnow in the main CI workflow.
8
+
9
+ on:
10
+ push:
11
+ branches: [main]
12
+ workflow_dispatch:
13
+
14
+ jobs:
15
+ live:
16
+ runs-on: ubuntu-latest
17
+ # Ephemeral throwaway databases: trust / empty-password auth so no credentials
18
+ # are committed (nothing for secret scanners to flag). Not a security model for
19
+ # anything beyond a disposable CI container on localhost.
20
+ services:
21
+ postgres:
22
+ image: postgres:16
23
+ env:
24
+ POSTGRES_USER: postgres
25
+ POSTGRES_HOST_AUTH_METHOD: trust
26
+ POSTGRES_DB: rsa_it
27
+ ports:
28
+ - 5432:5432
29
+ options: >-
30
+ --health-cmd "pg_isready -U postgres"
31
+ --health-interval 10s
32
+ --health-timeout 5s
33
+ --health-retries 5
34
+ mysql:
35
+ image: mysql:8
36
+ env:
37
+ MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
38
+ MYSQL_DATABASE: rsa_it
39
+ ports:
40
+ - 3306:3306
41
+ options: >-
42
+ --health-cmd "mysqladmin ping -h 127.0.0.1 --silent"
43
+ --health-interval 10s
44
+ --health-timeout 5s
45
+ --health-retries 10
46
+
47
+ steps:
48
+ - uses: actions/checkout@v4
49
+
50
+ - name: Set up Python
51
+ uses: actions/setup-python@v5
52
+ with:
53
+ python-version: "3.12"
54
+
55
+ - name: Install (drivers under test)
56
+ run: |
57
+ python -m pip install --upgrade pip
58
+ python -m pip install -e ".[dev,postgres,mysql,csv,owl]"
59
+
60
+ - name: Run integration conformance
61
+ env:
62
+ RUN_INTEGRATION: "1"
63
+ # No credentials in the DSNs (trust / empty-password containers above).
64
+ RSA_PG_DSN: postgresql://postgres@localhost:5432/rsa_it
65
+ RSA_MYSQL_DSN: mysql://root@localhost:3306/rsa_it
66
+ run: pytest -m integration -q
@@ -0,0 +1,21 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .eggs/
6
+ build/
7
+ dist/
8
+ .venv/
9
+ venv/
10
+ .env
11
+
12
+ # Tooling
13
+ .coverage
14
+ .pytest_cache/
15
+ .ruff_cache/
16
+ .mypy_cache/
17
+
18
+ # OS / editor
19
+ .DS_Store
20
+ .idea/
21
+ .vscode/
@@ -0,0 +1,174 @@
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
+
135
+ 6. Trademarks. This License does not grant permission to use the trade
136
+ names, trademarks, service marks, or product names of the Licensor,
137
+ except as required for reasonable and customary use in describing the
138
+ origin of the Work and reproducing the content of the NOTICE file.
139
+
140
+ 7. Disclaimer of Warranty. Unless required by applicable law or
141
+ agreed to in writing, Licensor provides the Work (and each
142
+ Contributor provides its Contributions) on an "AS IS" BASIS,
143
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
144
+ implied, including, without limitation, any warranties or conditions
145
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
146
+ PARTICULAR PURPOSE. You are solely responsible for determining the
147
+ appropriateness of using or redistributing the Work and assume any
148
+ risks associated with Your exercise of permissions under this License.
149
+
150
+ 8. Limitation of Liability. In no event and under no legal theory,
151
+ whether in tort (including negligence), contract, or otherwise,
152
+ unless required by applicable law (such as deliberate and grossly
153
+ negligent acts) or agreed to in writing, shall any Contributor be
154
+ liable to You for damages, including any direct, indirect, special,
155
+ incidental, or consequential damages of any character arising as a
156
+ result of this License or out of the use or inability to use the
157
+ Work (including but not limited to damages for loss of goodwill,
158
+ work stoppage, computer failure or malfunction, or any and all
159
+ other commercial damages or losses), even if such Contributor
160
+ has been advised of the possibility of such damages.
161
+
162
+ 9. Accepting Warranty or Additional Liability. While redistributing
163
+ the Work or Derivative Works thereof, You may choose to offer,
164
+ and charge a fee for, acceptance of support, warranty, indemnity,
165
+ or other liability obligations and/or rights consistent with this
166
+ License. However, in accepting such obligations, You may act only
167
+ on Your own behalf and on Your sole responsibility, not on behalf
168
+ of any other Contributor, and only if You agree to indemnify,
169
+ defend, and hold each Contributor harmless for any liability
170
+ incurred by, or claims asserted against, such Contributor by reason
171
+ of your accepting any such warranty or additional liability.
172
+
173
+ END OF TERMS AND CONDITIONS
174
+
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 2.4
2
+ Name: relational-schema-analyzer
3
+ Version: 0.1.0
4
+ Summary: Analyze a relational database schema into a conceptual model (OWL-capable) with mapping back to the source schema.
5
+ Project-URL: Homepage, https://github.com/ArthurKeen/relational-schema-analyzer
6
+ Project-URL: Repository, https://github.com/ArthurKeen/relational-schema-analyzer
7
+ Project-URL: Issues, https://github.com/ArthurKeen/relational-schema-analyzer/issues
8
+ Author: Arthur Keen
9
+ License: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: conceptual-model,mysql,ontology,owl,postgres,relational,schema,snowflake
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Database
21
+ Classifier: Topic :: Software Development :: Libraries
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: jsonschema>=4
25
+ Requires-Dist: pydantic>=2
26
+ Provides-Extra: anthropic
27
+ Requires-Dist: anthropic>=0.30; extra == 'anthropic'
28
+ Provides-Extra: csv
29
+ Requires-Dist: polars>=0.20; extra == 'csv'
30
+ Provides-Extra: databricks
31
+ Requires-Dist: databricks-sql-connector>=3; extra == 'databricks'
32
+ Provides-Extra: dev
33
+ Requires-Dist: duckdb>=1; extra == 'dev'
34
+ Requires-Dist: fakesnow>=0.11; extra == 'dev'
35
+ Requires-Dist: pytest>=8; extra == 'dev'
36
+ Requires-Dist: ruff>=0.5; extra == 'dev'
37
+ Requires-Dist: snowflake-connector-python>=3; extra == 'dev'
38
+ Provides-Extra: duckdb
39
+ Requires-Dist: duckdb>=1; extra == 'duckdb'
40
+ Provides-Extra: mcp
41
+ Requires-Dist: mcp>=1; extra == 'mcp'
42
+ Provides-Extra: mysql
43
+ Requires-Dist: pymysql>=1; extra == 'mysql'
44
+ Provides-Extra: openai
45
+ Requires-Dist: openai>=1; extra == 'openai'
46
+ Provides-Extra: openrouter
47
+ Requires-Dist: httpx>=0.27; extra == 'openrouter'
48
+ Provides-Extra: owl
49
+ Requires-Dist: rdflib>=7; extra == 'owl'
50
+ Provides-Extra: postgres
51
+ Requires-Dist: psycopg[binary]>=3; extra == 'postgres'
52
+ Provides-Extra: snowflake
53
+ Requires-Dist: snowflake-connector-python>=3; extra == 'snowflake'
54
+ Provides-Extra: sqlserver
55
+ Requires-Dist: pymssql>=2; extra == 'sqlserver'
56
+ Description-Content-Type: text/markdown
57
+
58
+ # relational-schema-analyzer
59
+
60
+ Analyze a **relational database schema** and produce a canonical **conceptual model**
61
+ (entities / relationships / properties), a **conceptual → physical mapping** back to the
62
+ source relational schema, and **metadata** (confidence, fingerprints, patterns). Optional
63
+ exports include **OWL** (Turtle / JSON-LD) for ontology pipelines.
64
+
65
+ This library is the relational analogue of
66
+ [`arangodb-schema-analyzer`](https://pypi.org/project/arangodb-schema-analyzer/) and
67
+ emits the **same tool-contract bundle shape** so that downstream consumers
68
+ (`arango-ontoextract`, transpilers, and ETL tools such as `r2g`) can treat relational and
69
+ ArangoDB sources interchangeably.
70
+
71
+ ```text
72
+ PostgreSQL / MySQL / SQL Server / Snowflake / CSV
73
+
74
+ ▼ introspect (live catalog views, not DDL parsing)
75
+ Physical Schema (tables, columns, PKs, FKs, types)
76
+
77
+ ▼ infer (deterministic baseline + optional LLM refinement)
78
+ { conceptualSchema, physicalMapping, metadata } ← canonical JSON bundle
79
+
80
+ ├──► OWL Turtle / JSON-LD (arango-ontoextract, ontology tooling)
81
+ ├──► relational physical view (SQL-native query tooling, future)
82
+ └──► consumed by r2g (drives ArangoDB MappingConfig generation)
83
+ ```
84
+
85
+ ## Status
86
+
87
+ Early development. **Phases 0–3 implemented**: the physical core (connectors, types,
88
+ FK inference) is extracted from `r2g`; the deterministic conceptual baseline emits a
89
+ contract-valid `{conceptualSchema, physicalMapping, metadata}` bundle with no LLM; and
90
+ OWL (Turtle / JSON-LD) exports + a CLI are in place. Next: optional LLM refinement
91
+ (Phase 4) and ecosystem integration (Phase 5). See:
92
+
93
+ - [`docs/DESIGN.md`](docs/DESIGN.md) — architecture, data model, tool contract, OWL mapping
94
+ - [`docs/IMPLEMENTATION-PLAN.md`](docs/IMPLEMENTATION-PLAN.md) — phased delivery plan & extraction inventory
95
+
96
+ ```python
97
+ from relational_schema_analyzer import (
98
+ create_connector, RelationalSchemaAnalyzer, export_owl_turtle,
99
+ )
100
+
101
+ physical = create_connector("postgresql", url, schema_name="public").get_schema()
102
+ analysis = RelationalSchemaAnalyzer().analyze(physical) # baseline, no LLM
103
+ bundle = analysis.to_bundle() # {conceptualSchema, physicalMapping, metadata}
104
+ ttl = export_owl_turtle(analysis)
105
+
106
+ # Optional LLM refinement (additive; falls back to baseline on any error):
107
+ refined = RelationalSchemaAnalyzer(
108
+ llm_provider="openai", # or "anthropic" / "openrouter" / a provider object
109
+ ).analyze(physical) # better names + embed/n-ary hints
110
+ ```
111
+
112
+ ```bash
113
+ relational-schema-analyzer snapshot --source postgresql --url "$DSN" -o physical.json
114
+ relational-schema-analyzer analyze --from-snapshot physical.json --pretty
115
+ relational-schema-analyzer owl --from-snapshot physical.json --format turtle -o schema.ttl
116
+ ```
117
+
118
+ Sources: `postgresql`, `mysql`, `sqlserver`, `snowflake`, `duckdb`, `databricks`, `csv`.
119
+
120
+ **MCP server** (optional, `pip install 'relational-schema-analyzer[mcp]'`) exposes the same
121
+ `snapshot` / `analyze` / `owl` operations over the v1 tool contract:
122
+
123
+ ```bash
124
+ relational-schema-analyzer-mcp # stdio (local IDE)
125
+ relational-schema-analyzer-mcp --transport sse --host 0.0.0.0 --port 8000 # remote (set RSA_MCP_TOKEN)
126
+ ```
127
+
128
+ ## Why this exists
129
+
130
+ Most of the relational **introspection** layer already exists and is battle-tested inside
131
+ the `r2g` (relational-to-graph) project, but it is welded to ArangoDB ETL and cannot be
132
+ reused elsewhere. This repo extracts that core into a paradigm-neutral library and adds the
133
+ **conceptual / OWL layer** that `r2g` never had, conforming to the contract the ArangoDB
134
+ analyzer already publishes.
135
+
136
+ ## License
137
+
138
+ Apache-2.0 — matching the surrounding Arango ecosystem libraries
139
+ (`arangodb-schema-analyzer`, `r2g`). See [`LICENSE`](LICENSE).
@@ -0,0 +1,82 @@
1
+ # relational-schema-analyzer
2
+
3
+ Analyze a **relational database schema** and produce a canonical **conceptual model**
4
+ (entities / relationships / properties), a **conceptual → physical mapping** back to the
5
+ source relational schema, and **metadata** (confidence, fingerprints, patterns). Optional
6
+ exports include **OWL** (Turtle / JSON-LD) for ontology pipelines.
7
+
8
+ This library is the relational analogue of
9
+ [`arangodb-schema-analyzer`](https://pypi.org/project/arangodb-schema-analyzer/) and
10
+ emits the **same tool-contract bundle shape** so that downstream consumers
11
+ (`arango-ontoextract`, transpilers, and ETL tools such as `r2g`) can treat relational and
12
+ ArangoDB sources interchangeably.
13
+
14
+ ```text
15
+ PostgreSQL / MySQL / SQL Server / Snowflake / CSV
16
+
17
+ ▼ introspect (live catalog views, not DDL parsing)
18
+ Physical Schema (tables, columns, PKs, FKs, types)
19
+
20
+ ▼ infer (deterministic baseline + optional LLM refinement)
21
+ { conceptualSchema, physicalMapping, metadata } ← canonical JSON bundle
22
+
23
+ ├──► OWL Turtle / JSON-LD (arango-ontoextract, ontology tooling)
24
+ ├──► relational physical view (SQL-native query tooling, future)
25
+ └──► consumed by r2g (drives ArangoDB MappingConfig generation)
26
+ ```
27
+
28
+ ## Status
29
+
30
+ Early development. **Phases 0–3 implemented**: the physical core (connectors, types,
31
+ FK inference) is extracted from `r2g`; the deterministic conceptual baseline emits a
32
+ contract-valid `{conceptualSchema, physicalMapping, metadata}` bundle with no LLM; and
33
+ OWL (Turtle / JSON-LD) exports + a CLI are in place. Next: optional LLM refinement
34
+ (Phase 4) and ecosystem integration (Phase 5). See:
35
+
36
+ - [`docs/DESIGN.md`](docs/DESIGN.md) — architecture, data model, tool contract, OWL mapping
37
+ - [`docs/IMPLEMENTATION-PLAN.md`](docs/IMPLEMENTATION-PLAN.md) — phased delivery plan & extraction inventory
38
+
39
+ ```python
40
+ from relational_schema_analyzer import (
41
+ create_connector, RelationalSchemaAnalyzer, export_owl_turtle,
42
+ )
43
+
44
+ physical = create_connector("postgresql", url, schema_name="public").get_schema()
45
+ analysis = RelationalSchemaAnalyzer().analyze(physical) # baseline, no LLM
46
+ bundle = analysis.to_bundle() # {conceptualSchema, physicalMapping, metadata}
47
+ ttl = export_owl_turtle(analysis)
48
+
49
+ # Optional LLM refinement (additive; falls back to baseline on any error):
50
+ refined = RelationalSchemaAnalyzer(
51
+ llm_provider="openai", # or "anthropic" / "openrouter" / a provider object
52
+ ).analyze(physical) # better names + embed/n-ary hints
53
+ ```
54
+
55
+ ```bash
56
+ relational-schema-analyzer snapshot --source postgresql --url "$DSN" -o physical.json
57
+ relational-schema-analyzer analyze --from-snapshot physical.json --pretty
58
+ relational-schema-analyzer owl --from-snapshot physical.json --format turtle -o schema.ttl
59
+ ```
60
+
61
+ Sources: `postgresql`, `mysql`, `sqlserver`, `snowflake`, `duckdb`, `databricks`, `csv`.
62
+
63
+ **MCP server** (optional, `pip install 'relational-schema-analyzer[mcp]'`) exposes the same
64
+ `snapshot` / `analyze` / `owl` operations over the v1 tool contract:
65
+
66
+ ```bash
67
+ relational-schema-analyzer-mcp # stdio (local IDE)
68
+ relational-schema-analyzer-mcp --transport sse --host 0.0.0.0 --port 8000 # remote (set RSA_MCP_TOKEN)
69
+ ```
70
+
71
+ ## Why this exists
72
+
73
+ Most of the relational **introspection** layer already exists and is battle-tested inside
74
+ the `r2g` (relational-to-graph) project, but it is welded to ArangoDB ETL and cannot be
75
+ reused elsewhere. This repo extracts that core into a paradigm-neutral library and adds the
76
+ **conceptual / OWL layer** that `r2g` never had, conforming to the contract the ArangoDB
77
+ analyzer already publishes.
78
+
79
+ ## License
80
+
81
+ Apache-2.0 — matching the surrounding Arango ecosystem libraries
82
+ (`arangodb-schema-analyzer`, `r2g`). See [`LICENSE`](LICENSE).