schemap-tool 0.6.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 (36) hide show
  1. schemap_tool-0.6.0/.gitattributes +2 -0
  2. schemap_tool-0.6.0/.github/workflows/schemap.yml +33 -0
  3. schemap_tool-0.6.0/PKG-INFO +19 -0
  4. schemap_tool-0.6.0/README.md +108 -0
  5. schemap_tool-0.6.0/Schemap Logo Square/Icon Dark.png +0 -0
  6. schemap_tool-0.6.0/Schemap Logo Square/Icon.png +0 -0
  7. schemap_tool-0.6.0/Schemap Logo Square/Text Logo (Dark).png +0 -0
  8. schemap_tool-0.6.0/Schemap Logo Square/Text Logo.png +0 -0
  9. schemap_tool-0.6.0/Schemap Logo Square/Text_Logo__Dark_-removebg-preview.png +0 -0
  10. schemap_tool-0.6.0/Schemap Logo Square/Text_Logo__Dark_-removebg-preview2.png +0 -0
  11. schemap_tool-0.6.0/Schemap Logo Square.zip +0 -0
  12. schemap_tool-0.6.0/docs/app.js +58 -0
  13. schemap_tool-0.6.0/docs/assets/Icon Dark.png +0 -0
  14. schemap_tool-0.6.0/docs/assets/Icon.png +0 -0
  15. schemap_tool-0.6.0/docs/assets/Text Logo (Dark).png +0 -0
  16. schemap_tool-0.6.0/docs/assets/Text Logo.png +0 -0
  17. schemap_tool-0.6.0/docs/assets/Text_Logo__Dark_-removebg-preview.png +0 -0
  18. schemap_tool-0.6.0/docs/assets/Text_Logo__Dark_-removebg-preview2.png +0 -0
  19. schemap_tool-0.6.0/docs/index.html +205 -0
  20. schemap_tool-0.6.0/docs/style.css +644 -0
  21. schemap_tool-0.6.0/llm_data_context.md +818 -0
  22. schemap_tool-0.6.0/pyproject.toml +36 -0
  23. schemap_tool-0.6.0/schemap/__init__.py +1 -0
  24. schemap_tool-0.6.0/schemap/cli.py +205 -0
  25. schemap_tool-0.6.0/schemap/config.py +31 -0
  26. schemap_tool-0.6.0/schemap/extractor.py +328 -0
  27. schemap_tool-0.6.0/schemap/license.py +115 -0
  28. schemap_tool-0.6.0/schemap/models.py +22 -0
  29. schemap_tool-0.6.0/schemap/renderer.py +24 -0
  30. schemap_tool-0.6.0/schemap/templates/context.md.j2 +21 -0
  31. schemap_tool-0.6.0/schemap.yaml +9 -0
  32. schemap_tool-0.6.0/tests/test_extractor.py +37 -0
  33. schemap_tool-0.6.0/tests/test_license.py +99 -0
  34. schemap_tool-0.6.0/tests/test_models.py +58 -0
  35. schemap_tool-0.6.0/tests/test_renderer.py +45 -0
  36. schemap_tool-0.6.0/uv.lock +1718 -0
@@ -0,0 +1,2 @@
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
@@ -0,0 +1,33 @@
1
+ name: Update Schemap Context
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ paths:
8
+ - 'migrations/**'
9
+ - 'alembic/versions/**'
10
+
11
+ jobs:
12
+ update-schema-map:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Install uv
18
+ uses: astral-sh/setup-uv@v3
19
+ with:
20
+ version: "0.1.0"
21
+
22
+ - name: Run Schemap Generate
23
+ run: |
24
+ # Note: Ensure your CI environment variables include your database credentials.
25
+ uv run schemap generate
26
+
27
+ - name: Commit and Push Context Map
28
+ run: |
29
+ git config --global user.name 'github-actions[bot]'
30
+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
31
+ git add llm_data_context.md
32
+ # Only commit if there are changes
33
+ git diff --quiet && git diff --staged --quiet || (git commit -m "docs: auto-update llm_data_context.md" && git push)
@@ -0,0 +1,19 @@
1
+ Metadata-Version: 2.4
2
+ Name: schemap-tool
3
+ Version: 0.6.0
4
+ Summary: A deterministic tool that outputs highly compressed database schemas
5
+ Author-email: Data Architect <architect@example.com>
6
+ Requires-Python: >=3.9
7
+ Requires-Dist: click>=8.1.0
8
+ Requires-Dist: jinja2>=3.1.0
9
+ Requires-Dist: libsql
10
+ Requires-Dist: oracledb
11
+ Requires-Dist: psycopg[binary]>=3.1.0
12
+ Requires-Dist: pydantic>=2.6.0
13
+ Requires-Dist: pymysql
14
+ Requires-Dist: pyyaml>=6.0.0
15
+ Requires-Dist: tiktoken>=0.6.0
16
+ Requires-Dist: watchdog>=4.0.0
17
+ Provides-Extra: dev
18
+ Requires-Dist: pytest-mock>=3.10.0; extra == 'dev'
19
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
@@ -0,0 +1,108 @@
1
+ <div align="center">
2
+ <img src="docs/assets/Text_Logo__Dark_-removebg-preview.png" alt="Schemap Logo" width="300" />
3
+ </div>
4
+
5
+ <br/>
6
+
7
+ <div align="center">
8
+ <strong>Token-Optimized Database Context for AI Pipelines.</strong>
9
+ </div>
10
+
11
+ <div align="center">
12
+ Don't waste 50,000 tokens on raw SQL dumps. Schemap is a zero-friction CLI that condenses your database schema into an LLM-perfect data contract.
13
+ </div>
14
+
15
+ <br/>
16
+
17
+ ## Why Schemap?
18
+
19
+ When building AI agents or RAG pipelines that interact with databases, developers usually dump raw `pg_dump` schemas into the context window. This wastes massive amounts of tokens, causes the LLM to hallucinate over irrelevant system tables, and breaks easily when schemas change.
20
+
21
+ **Schemap solves this.**
22
+ It natively connects to your database, strips out the noise, and generates a highly compressed, token-optimized Markdown file representing your exact data contract.
23
+
24
+ - **Zero-Friction:** No heavy setup. Generates a clean config in one command.
25
+ - **Multi-Dialect Routing:** Native support for PostgreSQL, MySQL, Oracle, Turso/libSQL, and SQLite.
26
+ - **Token Estimation:** Automatically calculates your exact token footprint (`~4,894 tokens`).
27
+ - **CI/CD Native:** Automatically run it in GitHub Actions to keep your context maps perfectly synced with your migrations.
28
+
29
+ ## Installation
30
+
31
+ Schemap is published on PyPI. Install it globally or within your project environment:
32
+
33
+ ```bash
34
+ pip install schemap
35
+ ```
36
+
37
+ *(Note: We highly recommend using [uv](https://github.com/astral-sh/uv) for blazing-fast environment management.)*
38
+
39
+ ## Quick Start
40
+
41
+ 1. **Initialize the configuration:**
42
+ Run the following command in your project root to generate a boilerplate `schemap.yaml` file:
43
+ ```bash
44
+ schemap init
45
+ ```
46
+
47
+ 2. **Configure your connection:**
48
+ Open `schemap.yaml` and paste your database connection URL. You can also define wildcard exclusions to ignore system tables.
49
+ ```yaml
50
+ database:
51
+ connection_url: "postgresql://user:password@localhost:5432/my_db"
52
+ exclude_tables:
53
+ - "spatial_ref_sys"
54
+ - "alembic_version"
55
+ - "*_history"
56
+ ```
57
+
58
+ 3. **Generate your context map:**
59
+ ```bash
60
+ schemap generate
61
+ ```
62
+ *Output:*
63
+ ```text
64
+ -> Loading configuration from ./schemap.yaml... OK
65
+ -> Connecting to database... Connected. Found 39 active tables
66
+ -> Validating schema objects contract... OK
67
+ -> Compiling context engine via Jinja2... OK
68
+ [SUCCESS] Context map generated successfully at ./llm_data_context.md [14.0 KB / ~4,894 tokens]
69
+ ```
70
+
71
+ ## Supported Databases
72
+
73
+ - PostgreSQL (`postgresql://...`)
74
+ - Turso / remote libSQL (`libsql://...`)
75
+ - Local SQLite (`sqlite:///...`)
76
+ - MySQL (`mysql://...`)
77
+ - Oracle (`oracle://...`)
78
+
79
+ ## Continuous Integration (CI/CD)
80
+
81
+ Want to automate your context map generation every time you merge a database migration?
82
+
83
+ Run:
84
+ ```bash
85
+ schemap init-ci
86
+ ```
87
+ This drops a ready-to-use `.github/workflows/schemap.yml` action into your repository that runs Schemap and commits the new Markdown file automatically.
88
+
89
+ ## Licensing
90
+
91
+ Schemap operates on a Frictionless License Model.
92
+ - **Developer Tier (Free):** Use Schemap for free locally on databases with up to 10 tables.
93
+ - **Professional & Team Tiers:** For unlimited tables, wildcard filtering, and CI/CD pipeline automation, purchase a license key at [schemap.com](https://your-username.github.io/schemap).
94
+
95
+ Once purchased, simply drop your key into the `schemap.yaml`:
96
+ ```yaml
97
+ database:
98
+ license_key: "YOUR_LICENSE_KEY_HERE"
99
+ ```
100
+
101
+ ## Built With
102
+ - `psycopg` (PostgreSQL)
103
+ - `libsql` (Turso)
104
+ - `pymysql` (MySQL)
105
+ - `oracledb` (Oracle)
106
+ - `pydantic` v2 (Strict type-safety)
107
+ - `jinja2` (Markdown compilation)
108
+ - `tiktoken` (Token counting)
@@ -0,0 +1,58 @@
1
+ document.addEventListener('DOMContentLoaded', () => {
2
+ // Typing effect for the terminal
3
+ const cmdElement = document.getElementById('type-cmd');
4
+ const originalText = "uv run schemap generate";
5
+ cmdElement.textContent = "";
6
+
7
+ // Add cursor
8
+ const cursor = document.createElement('span');
9
+ cursor.className = 'cursor';
10
+ cmdElement.parentNode.appendChild(cursor);
11
+
12
+ let i = 0;
13
+ const typeInterval = setInterval(() => {
14
+ if (i < originalText.length) {
15
+ cmdElement.textContent += originalText.charAt(i);
16
+ i++;
17
+ } else {
18
+ clearInterval(typeInterval);
19
+ // Wait 500ms then remove cursor and show output
20
+ setTimeout(() => {
21
+ cursor.remove();
22
+ showOutput();
23
+ }, 500);
24
+ }
25
+ }, 100);
26
+
27
+ function showOutput() {
28
+ const delays = [400, 800, 1000, 1100, 1300];
29
+ for (let j = 1; j <= 5; j++) {
30
+ setTimeout(() => {
31
+ const el = document.getElementById(`out-${j}`);
32
+ if (el) {
33
+ el.classList.remove('hidden');
34
+ }
35
+ }, delays[j-1]);
36
+ }
37
+ // Copy Install Command functionality
38
+ const copyBtn = document.getElementById('copy-install-btn');
39
+ if (copyBtn) {
40
+ copyBtn.addEventListener('click', (e) => {
41
+ e.preventDefault();
42
+ navigator.clipboard.writeText('pip install schemap').then(() => {
43
+ const originalText = copyBtn.textContent;
44
+ copyBtn.textContent = 'Copied to Clipboard!';
45
+ copyBtn.style.color = 'var(--success)';
46
+ copyBtn.style.borderColor = 'var(--success)';
47
+
48
+ setTimeout(() => {
49
+ copyBtn.textContent = originalText;
50
+ copyBtn.style.color = '';
51
+ copyBtn.style.borderColor = '';
52
+ }, 2000);
53
+ }).catch(err => {
54
+ console.error('Failed to copy: ', err);
55
+ });
56
+ });
57
+ }
58
+ });
Binary file
@@ -0,0 +1,205 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Schemap | Token-Optimized Database Context</title>
8
+ <link rel="preconnect" href="https://fonts.googleapis.com">
9
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
+ <link
11
+ href="https://fonts.googleapis.com/css2?family=Red+Hat+Display:wght@400;500;700&family=JetBrains+Mono:wght@400;500&display=swap"
12
+ rel="stylesheet">
13
+ <link rel="stylesheet" href="style.css?v=2">
14
+ <link rel="icon" type="image/png" href="assets/Icon Dark.png">
15
+ </head>
16
+
17
+ <body>
18
+ <nav class="navbar">
19
+ <div class="nav-container">
20
+ <a href="#" class="logo">
21
+ <img src="assets/Text_Logo__Dark_-removebg-preview2.png" alt="Schemap Logo" class="nav-logo">
22
+ </a>
23
+ <div class="nav-links">
24
+ <a href="#features" class="hide-mobile">Features</a>
25
+ <a href="#pricing" class="hide-mobile">Pricing</a>
26
+ <a href="https://github.com/alansyahmi/Schemap" target="_blank" class="nav-btn hide-mobile">GitHub</a>
27
+ <a href="#installation" class="btn btn-primary show-mobile"
28
+ style="color: #000 !important; font-weight: 600; padding: 0.5rem 1rem; font-size: 0.875rem; margin-left: 1rem;">Get
29
+ for Free</a>
30
+ </div>
31
+ </div>
32
+ </nav>
33
+
34
+ <header class="hero">
35
+ <div class="hero-content">
36
+ <div class="badge">v0.1.0 Released</div>
37
+ <h1 class="hero-title">Token-Optimized Database Context for AI Pipelines.</h1>
38
+ <p class="hero-subtitle">Don't waste 50,000 tokens on raw SQL dumps. Schemap is a zero-friction CLI that
39
+ condenses your database schema into an LLM-perfect data contract.</p>
40
+ <div class="hero-actions">
41
+ <a href="#pricing" class="btn btn-primary">Get License Key</a>
42
+ <a href="#installation" class="btn btn-secondary">Install Now</a>
43
+ </div>
44
+ </div>
45
+
46
+ <div class="hero-terminal">
47
+ <div class="terminal-header">
48
+ <div class="mac-btns">
49
+ <span class="close"></span>
50
+ <span class="minimize"></span>
51
+ <span class="maximize"></span>
52
+ </div>
53
+ <div class="terminal-title">bash</div>
54
+ </div>
55
+ <div class="terminal-body" id="terminal-body">
56
+ <div class="line"><span class="prompt">$</span> <span class="command" id="type-cmd">uv run schemap
57
+ generate</span></div>
58
+ <div class="output hidden" id="out-1"><span class="success">-&gt;</span> Loading configuration from
59
+ ./schemap.yaml... <span class="success">OK</span></div>
60
+ <div class="output hidden" id="out-2"><span class="success">-&gt;</span> Connecting to database... <span
61
+ class="success">Connected. Found 39 active tables</span></div>
62
+ <div class="output hidden" id="out-3"><span class="success">-&gt;</span> Validating schema objects
63
+ contract... <span class="success">OK</span></div>
64
+ <div class="output hidden" id="out-4"><span class="success">-&gt;</span> Compiling context engine via
65
+ Jinja2... <span class="success">OK</span></div>
66
+ <div class="output hidden" id="out-5"><br><span class="success-bold">[SUCCESS]</span> Context map
67
+ generated successfully at ./llm_data_context.md <span class="highlight-token">[14.0 KB / ~4,894
68
+ tokens]</span></div>
69
+ </div>
70
+ </div>
71
+ </header>
72
+
73
+ <section id="features" class="features">
74
+ <div class="section-container">
75
+ <h2 class="section-title">Built for the Modern AI Engineer</h2>
76
+ <p class="section-subtitle">A highly decoupled Python pipeline enforcing strict data contracts.</p>
77
+
78
+ <div class="feature-grid">
79
+ <div class="feature-card">
80
+ <div class="feature-icon">
81
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
82
+ stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
83
+ <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path>
84
+ <path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path>
85
+ </svg>
86
+ </div>
87
+ <h3>Multi-Dialect Routing</h3>
88
+ <p>Natively connects to PostgreSQL, Turso/libSQL, MySQL, Oracle, and local SQLite with zero instant
89
+ client dependencies required.</p>
90
+ </div>
91
+ <div class="feature-card">
92
+ <div class="feature-icon">
93
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
94
+ stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
95
+ <circle cx="12" cy="12" r="10"></circle>
96
+ <polyline points="12 6 12 12 16 14"></polyline>
97
+ </svg>
98
+ </div>
99
+ <h3>The Leaky Bucket Cache</h3>
100
+ <p>If you're hacking on an airplane or the network drops, Schemap's obfuscated offline cache gives
101
+ you a 72-hour grace period.</p>
102
+ </div>
103
+ <div class="feature-card">
104
+ <div class="feature-icon">
105
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
106
+ stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
107
+ <path
108
+ d="M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16">
109
+ </path>
110
+ </svg>
111
+ </div>
112
+ <h3>CI/CD Pipeline Native</h3>
113
+ <p>Run `uv run schemap init-ci` to automatically generate a GitHub Action. Your context window stays
114
+ up-to-date with every PR.</p>
115
+ </div>
116
+ </div>
117
+ </div>
118
+ </section>
119
+
120
+ <section id="installation" class="installation">
121
+ <div class="section-container">
122
+ <div class="install-card">
123
+ <h2>Install in 2 Seconds</h2>
124
+ <p>Schemap leverages `uv` to maintain a zero-friction footprint.</p>
125
+ <div class="code-block">
126
+ <code>pip install schemap</code>
127
+ </div>
128
+ <div class="code-block mt">
129
+ <code>uv run schemap init</code>
130
+ </div>
131
+ <p class="install-desc">This generates your <code>schemap.yaml</code>. Update it with your database connection details:</p>
132
+ <div class="code-block mt" style="background: rgba(0,0,0,0.5); padding: 1.5rem; text-align: left; font-size: 0.85rem; line-height: 1.5;">
133
+ <code style="color: var(--text-secondary); white-space: pre-wrap;"><span style="color: var(--accent);">database:</span>
134
+ url: <span style="color: var(--success);">"libsql://my-database.turso.io"</span>
135
+ <span style="color: #6b7280;"># Provide your auth token directly or use SCHEMAP_AUTH_TOKEN env var</span>
136
+ auth_token: <span style="color: var(--success);">"your-database-auth-token"</span>
137
+
138
+ <span style="color: var(--accent);">license_key:</span> <span style="color: var(--success);">"your-license-key"</span></code>
139
+ </div>
140
+ </div>
141
+ </div>
142
+ </section>
143
+
144
+ <section id="pricing" class="pricing">
145
+ <div class="section-container">
146
+ <h2 class="section-title">Frictionless Licensing</h2>
147
+ <p class="section-subtitle">Simple, lifetime value. No heavy web logins required.</p>
148
+
149
+ <div class="pricing-grid">
150
+ <div class="price-card">
151
+ <div class="tier-name">Developer</div>
152
+ <div class="price">Free</div>
153
+ <p class="tier-desc">For students and indie devs building local side projects.</p>
154
+ <ul class="features-list">
155
+ <li>Maximum 10 database tables</li>
156
+ <li>Local execution only</li>
157
+ <li>Markdown code generation</li>
158
+ <li>Token estimations</li>
159
+ </ul>
160
+ <button id="copy-install-btn" class="btn btn-secondary full-width"
161
+ style="font-family: inherit; font-size: 1rem; cursor: pointer;">Copy Install Command</button>
162
+ </div>
163
+
164
+ <div class="price-card featured">
165
+ <div class="featured-badge">Most Popular</div>
166
+ <div class="tier-name">Professional</div>
167
+ <div class="price">$49<span class="period">/mo</span></div>
168
+ <p class="tier-desc">For solo AI engineers and early-stage startups.</p>
169
+ <ul class="features-list">
170
+ <li><strong>Unlimited</strong> database tables</li>
171
+ <li>Up to 3 active database connections</li>
172
+ <li>Email support</li>
173
+ <li>Wildcard exclusion globbing</li>
174
+ </ul>
175
+ <a href="#" class="btn btn-primary full-width">Buy License</a>
176
+ </div>
177
+
178
+ <div class="price-card">
179
+ <div class="tier-name">Team</div>
180
+ <div class="price">$99<span class="period">/mo</span></div>
181
+ <p class="tier-desc">For tech teams needing automated context synchronization.</p>
182
+ <ul class="features-list">
183
+ <li><strong>Unlimited</strong> database tables</li>
184
+ <li><strong>CI/CD Pipeline Execution</strong></li>
185
+ <li>Automated GitHub Actions sync</li>
186
+ <li>Priority team support</li>
187
+ </ul>
188
+ <a href="#" class="btn btn-secondary full-width">Buy Team License</a>
189
+ </div>
190
+ </div>
191
+ </div>
192
+ </section>
193
+
194
+ <footer>
195
+ <div class="footer-content">
196
+ <img src="assets/Icon Dark.png" alt="Schemap Icon" height="24">
197
+ <p>&copy; 2026 Schemap. A zero-friction dev tool.</p>
198
+ <p>Developed by Swarty</p>
199
+ </div>
200
+ </footer>
201
+
202
+ <script src="app.js"></script>
203
+ </body>
204
+
205
+ </html>