toolframe-sql-postgres 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 (38) hide show
  1. toolframe_sql_postgres-0.2.0/.github/workflows/ci.yml +44 -0
  2. toolframe_sql_postgres-0.2.0/.github/workflows/postgres.yml +93 -0
  3. toolframe_sql_postgres-0.2.0/.github/workflows/publish.yml +65 -0
  4. toolframe_sql_postgres-0.2.0/.github/workflows/quality.yml +63 -0
  5. toolframe_sql_postgres-0.2.0/.gitignore +15 -0
  6. toolframe_sql_postgres-0.2.0/.pre-commit-config.yaml +29 -0
  7. toolframe_sql_postgres-0.2.0/CONTRIBUTING.md +49 -0
  8. toolframe_sql_postgres-0.2.0/LICENSE +202 -0
  9. toolframe_sql_postgres-0.2.0/NOTICE +2 -0
  10. toolframe_sql_postgres-0.2.0/PKG-INFO +104 -0
  11. toolframe_sql_postgres-0.2.0/README.md +86 -0
  12. toolframe_sql_postgres-0.2.0/cchk.toml +10 -0
  13. toolframe_sql_postgres-0.2.0/docs/adr/0001-plugin-storage-boundary.md +8 -0
  14. toolframe_sql_postgres-0.2.0/docs/adr/0002-explicit-database-dialects.md +8 -0
  15. toolframe_sql_postgres-0.2.0/docs/adr/0003-application-database-boundary.md +7 -0
  16. toolframe_sql_postgres-0.2.0/docs/adr/0004-separate-provisioning-credentials.md +8 -0
  17. toolframe_sql_postgres-0.2.0/docs/adr/0005-pre-migration-database-backups.md +9 -0
  18. toolframe_sql_postgres-0.2.0/docs/development.md +54 -0
  19. toolframe_sql_postgres-0.2.0/docs/glossary.md +40 -0
  20. toolframe_sql_postgres-0.2.0/docs/operations.md +85 -0
  21. toolframe_sql_postgres-0.2.0/docs/releasing.md +68 -0
  22. toolframe_sql_postgres-0.2.0/docs/storage-contract.md +76 -0
  23. toolframe_sql_postgres-0.2.0/pyproject.toml +44 -0
  24. toolframe_sql_postgres-0.2.0/scripts/check.py +28 -0
  25. toolframe_sql_postgres-0.2.0/scripts/check_branch_name.py +59 -0
  26. toolframe_sql_postgres-0.2.0/scripts/validate_release.py +181 -0
  27. toolframe_sql_postgres-0.2.0/src/toolframe_sql_postgres/__init__.py +1 -0
  28. toolframe_sql_postgres-0.2.0/src/toolframe_sql_postgres/backup.py +163 -0
  29. toolframe_sql_postgres-0.2.0/src/toolframe_sql_postgres/cli.py +221 -0
  30. toolframe_sql_postgres-0.2.0/src/toolframe_sql_postgres/config.py +104 -0
  31. toolframe_sql_postgres-0.2.0/src/toolframe_sql_postgres/plugin.py +590 -0
  32. toolframe_sql_postgres-0.2.0/src/toolframe_sql_postgres/provision.py +348 -0
  33. toolframe_sql_postgres-0.2.0/src/toolframe_sql_postgres/sql.py +203 -0
  34. toolframe_sql_postgres-0.2.0/tests/conftest.py +122 -0
  35. toolframe_sql_postgres-0.2.0/tests/test_first_party.py +333 -0
  36. toolframe_sql_postgres-0.2.0/tests/test_like_escape.py +29 -0
  37. toolframe_sql_postgres-0.2.0/tests/test_storage.py +526 -0
  38. toolframe_sql_postgres-0.2.0/uv.lock +805 -0
@@ -0,0 +1,44 @@
1
+ name: Validate Python distribution
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ workflow_dispatch:
8
+ workflow_call:
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ jobs:
14
+ validate:
15
+ runs-on: ${{ matrix.os }}
16
+ timeout-minutes: 25
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ os: [ubuntu-24.04, macos-15]
21
+ steps:
22
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
23
+ with:
24
+ persist-credentials: false
25
+ - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
26
+ with:
27
+ python-version: '3.14.7'
28
+ - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
29
+ with:
30
+ version: '0.12.8'
31
+ enable-cache: false
32
+ - name: Test and install wheel and source distribution
33
+ run: python scripts/validate_release.py --output dist/validated
34
+ - name: Retain only validated distributions
35
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
36
+ with:
37
+ name: python-dist-${{ matrix.os }}
38
+ path: dist/validated/*
39
+ if-no-files-found: error
40
+ retention-days: 14
41
+
42
+ postgres:
43
+ uses: ./.github/workflows/postgres.yml
44
+ secrets: inherit
@@ -0,0 +1,93 @@
1
+ name: PostgreSQL integration
2
+ on:
3
+ workflow_dispatch:
4
+ workflow_call:
5
+ permissions:
6
+ contents: read
7
+ jobs:
8
+ storage:
9
+ runs-on: ubuntu-24.04
10
+ timeout-minutes: 20
11
+ services:
12
+ postgres:
13
+ image: postgres:16.14
14
+ env:
15
+ POSTGRES_PASSWORD: disposable-ci-database
16
+ ports:
17
+ - 5432:5432
18
+ options: >-
19
+ --health-cmd pg_isready --health-interval 5s
20
+ --health-timeout 5s --health-retries 12
21
+ env:
22
+ TOOLFRAME_POSTGRES_TEST_ADMIN_DSN: postgresql://postgres:disposable-ci-database@127.0.0.1:5432/postgres
23
+ steps:
24
+ - name: Check out provider
25
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
26
+ with:
27
+ path: toolframe-sql-postgres
28
+ persist-credentials: false
29
+ - name: Check out toolframe-sdk
30
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
31
+ with:
32
+ repository: ${{ vars.TOOLFRAME_REPOSITORY_OWNER || github.repository_owner }}/toolframe-sdk
33
+ token: ${{ secrets.TOOLFRAME_READ_TOKEN || github.token }}
34
+ ref: 2cd153ec36c585a9adb5ad566effc2985d9e222d
35
+ path: toolframe-sdk
36
+ persist-credentials: false
37
+ - name: Check out toolframe-auth
38
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
39
+ with:
40
+ repository: ${{ vars.TOOLFRAME_REPOSITORY_OWNER || github.repository_owner }}/toolframe-auth
41
+ token: ${{ secrets.TOOLFRAME_READ_TOKEN || github.token }}
42
+ ref: f43c623cafb1483f3387935d7ef2690ca52088c9
43
+ path: toolframe-auth
44
+ persist-credentials: false
45
+ - name: Check out toolframe-mcp-auth
46
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
47
+ with:
48
+ repository: ${{ vars.TOOLFRAME_REPOSITORY_OWNER || github.repository_owner }}/toolframe-mcp-auth
49
+ token: ${{ secrets.TOOLFRAME_READ_TOKEN || github.token }}
50
+ ref: 37b53ac0b37637c953cf5e40e59b5dcde8ab2c4b
51
+ path: toolframe-mcp-auth
52
+ persist-credentials: false
53
+ - name: Check out toolframe-oidc-auth
54
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
55
+ with:
56
+ repository: ${{ vars.TOOLFRAME_REPOSITORY_OWNER || github.repository_owner }}/toolframe-oidc-auth
57
+ token: ${{ secrets.TOOLFRAME_READ_TOKEN || github.token }}
58
+ ref: 5d88289871c7e961216536ddde812510e319a7fe
59
+ path: toolframe-oidc-auth
60
+ persist-credentials: false
61
+ - name: Check out toolframe-demo-entry-register
62
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
63
+ with:
64
+ repository: ${{ vars.TOOLFRAME_REPOSITORY_OWNER || github.repository_owner }}/toolframe-demo-entry-register
65
+ token: ${{ secrets.TOOLFRAME_READ_TOKEN || github.token }}
66
+ ref: 638e2163bd1f50f3715e05b418ac9095b4003513
67
+ path: toolframe-demo-entry-register
68
+ persist-credentials: false
69
+ - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97
70
+ with:
71
+ python-version: '3.14.7'
72
+ - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7
73
+ with:
74
+ version: '0.12.8'
75
+ enable-cache: false
76
+ - name: Install matching PostgreSQL client tools
77
+ run: |
78
+ sudo apt-get update
79
+ sudo apt-get install -y postgresql-client-16
80
+ echo 'TOOLFRAME_POSTGRES_PG_DUMP=/usr/lib/postgresql/16/bin/pg_dump' >> "$GITHUB_ENV"
81
+ echo 'TOOLFRAME_POSTGRES_PG_RESTORE=/usr/lib/postgresql/16/bin/pg_restore' >> "$GITHUB_ENV"
82
+ - name: Test real storage and first-party consumers
83
+ working-directory: toolframe-sql-postgres
84
+ run: |
85
+ uv sync --locked --group dev --group compatibility
86
+ uv run --no-sync python scripts/check.py
87
+ uv build --no-sources
88
+ - name: Retain distributions
89
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
90
+ with:
91
+ name: postgres-distributions
92
+ path: toolframe-sql-postgres/dist/*
93
+ if-no-files-found: error
@@ -0,0 +1,65 @@
1
+ name: Publish Python distribution
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ index:
7
+ description: Package index; run against the matching vVERSION tag
8
+ type: choice
9
+ options: [testpypi, pypi]
10
+ default: testpypi
11
+ required: true
12
+
13
+ permissions:
14
+ contents: read
15
+
16
+ concurrency:
17
+ group: publish-${{ inputs.index }}
18
+ cancel-in-progress: false
19
+
20
+ jobs:
21
+ release-tag:
22
+ runs-on: ubuntu-24.04
23
+ timeout-minutes: 5
24
+ steps:
25
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
26
+ with:
27
+ persist-credentials: false
28
+ - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
29
+ with:
30
+ python-version: '3.14.7'
31
+ - name: Require the exact package version tag
32
+ env:
33
+ RELEASE_REF: ${{ github.ref }}
34
+ run: |
35
+ python - <<'PYCODE'
36
+ import os, pathlib, tomllib
37
+ project = tomllib.loads(pathlib.Path('pyproject.toml').read_text())['project']
38
+ expected = 'refs/tags/v' + project['version']
39
+ if os.environ['RELEASE_REF'] != expected:
40
+ raise SystemExit('Publication requires ' + expected)
41
+ PYCODE
42
+
43
+ validate:
44
+ needs: release-tag
45
+ uses: ./.github/workflows/ci.yml
46
+ secrets: inherit
47
+
48
+ publish:
49
+ needs: [release-tag, validate]
50
+ runs-on: ubuntu-24.04
51
+ timeout-minutes: 10
52
+ environment:
53
+ name: ${{ inputs.index }}
54
+ permissions:
55
+ contents: read
56
+ id-token: write
57
+ steps:
58
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
59
+ with:
60
+ name: python-dist-ubuntu-24.04
61
+ path: dist/
62
+ - uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
63
+ with:
64
+ packages-dir: dist/
65
+ repository-url: ${{ inputs.index == 'testpypi' && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }}
@@ -0,0 +1,63 @@
1
+ name: Code quality
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ types: [opened, synchronize, reopened, edited]
8
+ workflow_dispatch:
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ jobs:
14
+ branch-policy:
15
+ runs-on: ubuntu-24.04
16
+ timeout-minutes: 5
17
+ steps:
18
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
19
+ with:
20
+ persist-credentials: false
21
+ - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
22
+ with:
23
+ python-version: '3.14.7'
24
+ - name: Check the actual source branch
25
+ env:
26
+ BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
27
+ run: python scripts/check_branch_name.py "$BRANCH_NAME"
28
+
29
+ code-quality:
30
+ runs-on: ubuntu-24.04
31
+ timeout-minutes: 10
32
+ steps:
33
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
34
+ with:
35
+ persist-credentials: false
36
+ - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
37
+ with:
38
+ version: '0.12.8'
39
+ enable-cache: false
40
+ - name: Check Python lint and formatting
41
+ run: uvx prek==0.5.5 run ruff-check ruff-format --all-files --show-diff-on-failure
42
+
43
+ commit-policy:
44
+ if: github.event_name == 'pull_request'
45
+ runs-on: ubuntu-24.04
46
+ timeout-minutes: 10
47
+ permissions:
48
+ contents: read
49
+ pull-requests: read
50
+ steps:
51
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
52
+ with:
53
+ fetch-depth: 0
54
+ persist-credentials: false
55
+ - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
56
+ with:
57
+ python-version: '3.14.7'
58
+ - uses: commit-check/commit-check-action@a61779784a953fd9047c001c102cfeac5cf26964 # commit-check 2.18.3
59
+ with:
60
+ message: true
61
+ branch: false
62
+ pr-title: true
63
+ pr-comments: false
@@ -0,0 +1,15 @@
1
+ /.venv/
2
+ /dist/
3
+ /build/
4
+ __pycache__/
5
+ *.py[cod]
6
+ .pytest_cache/
7
+ .ruff_cache/
8
+ .coverage
9
+ .env
10
+ .env.*
11
+
12
+ # Local working documents, issue state, and development worktrees.
13
+ /.local/
14
+ /.issues/
15
+ /.worktrees/
@@ -0,0 +1,29 @@
1
+ default_install_hook_types: [pre-commit, commit-msg]
2
+ default_stages: [pre-commit]
3
+ default_language_version:
4
+ python: python3.11
5
+
6
+ repos:
7
+ - repo: local
8
+ hooks:
9
+ - id: check-branch-name
10
+ name: Check branch naming policy
11
+ entry: python scripts/check_branch_name.py
12
+ language: python
13
+ always_run: true
14
+ pass_filenames: false
15
+ - repo: https://github.com/astral-sh/ruff-pre-commit
16
+ rev: v0.16.8
17
+ hooks:
18
+ - id: ruff-check
19
+ types_or: [python, pyi]
20
+ files: '^(src|tests|scripts)/'
21
+ - id: ruff-format
22
+ types_or: [python, pyi]
23
+ args: [--check]
24
+ files: '^(src|tests|scripts)/'
25
+ - repo: https://github.com/commit-check/commit-check
26
+ rev: v2.18.3
27
+ hooks:
28
+ - id: check-message
29
+ stages: [commit-msg]
@@ -0,0 +1,49 @@
1
+ # Contributing
2
+
3
+ ## Commit hooks
4
+
5
+ Install [prek](https://prek.j178.dev/) and enable the repository's hooks:
6
+
7
+ ```sh
8
+ uv tool install prek==0.5.5
9
+ prek install --allow-missing-config
10
+ prek run --all-files
11
+ ```
12
+
13
+ The missing-config option allows older worktrees without this configuration to
14
+ keep working. Worktrees containing `.pre-commit-config.yaml` still run the checks.
15
+ The `pre-commit` hook checks the branch name, Python lint, and formatting. The
16
+ `commit-msg` hook checks Conventional Commits. Both Ruff hooks only check files;
17
+ they do not rewrite a commit's contents. Fix lint and formatting explicitly:
18
+
19
+ ```sh
20
+ uvx ruff==0.16.8 check --fix src tests scripts
21
+ uvx ruff==0.16.8 format src tests scripts
22
+ prek run --all-files
23
+ ```
24
+
25
+ The Ruff version and checked paths are pinned in
26
+ [the hook configuration](.pre-commit-config.yaml); the Python rules remain in
27
+ [pyproject.toml](pyproject.toml). CI uses these same hooks on all tracked files
28
+ within their configured paths. Existing package, integration, and release checks
29
+ run independently.
30
+
31
+ ## Branches and commits
32
+
33
+ [cchk.toml](cchk.toml) defines the allowed branch and commit types. Work branches
34
+ use `feat/`, `fix/`, `release/`, or `chore/`, followed by lowercase ASCII letters
35
+ and digits separated by single hyphens. Release versions may also contain dots,
36
+ as in `release/v1.2.0-rc.1`; every separator must have an alphanumeric character on
37
+ both sides. The default branch `main` is the standalone exception.
38
+
39
+ Commit types are independent of branch types: for example,
40
+ `docs: clarify setup` is valid on `chore/update-docs`. Commit-check uses Conventional
41
+ Commits with its default subject length of 5–80 characters. Pull requests check
42
+ their commits and title so the title can be used for a Conventional Commit when
43
+ squash merging.
44
+
45
+ Local hooks can be bypassed. CI reports `branch-policy`, `code-quality`, and
46
+ `commit-policy`; maintainers must configure required status checks separately to
47
+ make passing checks a merge requirement.
48
+
49
+ For package setup and broader verification, see [the development guide](docs/development.md).
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,2 @@
1
+ toolframe-sql-postgres
2
+ Copyright 2026 byfb
@@ -0,0 +1,104 @@
1
+ Metadata-Version: 2.5
2
+ Name: toolframe-sql-postgres
3
+ Version: 0.2.0
4
+ Summary: Managed PostgreSQL stores for Toolframe plugins
5
+ Project-URL: Homepage, https://github.com/toolframe/toolframe-sql-postgres
6
+ Project-URL: Repository, https://github.com/toolframe/toolframe-sql-postgres
7
+ Project-URL: Documentation, https://github.com/toolframe/toolframe-sql-postgres#readme
8
+ Project-URL: Issues, https://github.com/toolframe/toolframe-sql-postgres/issues
9
+ Author-email: byfb <62798989+byfb@users.noreply.github.com>
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ License-File: NOTICE
13
+ Requires-Python: >=3.14
14
+ Requires-Dist: pglast==8.4
15
+ Requires-Dist: psycopg[binary]<4,>=3.3
16
+ Requires-Dist: toolframe-sdk==0.4.0
17
+ Description-Content-Type: text/markdown
18
+
19
+ # Toolframe PostgreSQL storage
20
+
21
+ `sql-postgres` stores Toolframe plugin data in PostgreSQL. Entry Register,
22
+ Auth, MCP Auth and OIDC Auth use a separate schema per plugin inside one database
23
+ per application environment. Database access is loaded **only from the runtime
24
+ process environment**; credentials do not belong in `toolframe.toml`.
25
+
26
+ This release requires Toolframe SDK 0.4 and Core 0.7. Run one Core per
27
+ application. Core 0.7 can separately store its management journal in a dedicated
28
+ PostgreSQL database; SQLite remains the default. Configuration, private keys and
29
+ artifacts still need a persistent application home. PostgreSQL storage does not
30
+ make Core stateless or enable multiple replicas.
31
+ Existing SQLite data is not imported. Plugins are trusted Python code.
32
+
33
+ ## Quick start
34
+
35
+ Use Python 3.14+, PostgreSQL 16+, and `pg_dump` / `pg_restore` with the **same major
36
+ version** as the server. PostgreSQL 16 is the integration-test baseline.
37
+
38
+ Install the host and provider CLI from PyPI:
39
+
40
+ ```sh
41
+ uv venv --python 3.14.7 .venv
42
+ uv pip install --python .venv/bin/python \
43
+ toolframe-core==0.7.0 toolframe-sql-postgres==0.2.0
44
+ .venv/bin/toolframe-core --home ./app init
45
+ ```
46
+
47
+ Read `[application].id` from `app/toolframe.toml`. Supply an administrator DSN from
48
+ your secret manager as `TOOLFRAME_POSTGRES_SETUP_DSN`. It is used only by setup.
49
+ The CLI output file contains generated runtime credentials and must remain private.
50
+
51
+ ```sh
52
+ .venv/bin/toolframe-postgres setup \
53
+ --application-id '<id from app/toolframe.toml>' \
54
+ --database toolframe_development \
55
+ --owner entry-register --owner auth --owner mcp-auth --owner oidc-auth \
56
+ --output ./app/.toolframe/postgres-environment.json
57
+ unset TOOLFRAME_POSTGRES_SETUP_DSN
58
+ ```
59
+
60
+ Add the provider to `app/toolframe.toml`:
61
+
62
+ ```toml
63
+ [plugins.sql-postgres]
64
+ source = "pypi:toolframe-sql-postgres==0.2.0"
65
+ enabled = true
66
+
67
+ [bindings]
68
+ "toolframe.sql" = "sql-postgres"
69
+ ```
70
+
71
+ This configuration sends every SQL consumer to PostgreSQL. Core builds with
72
+ multiple SQL provider support can also run SQLite, using an explicit per-plugin
73
+ override such as `"entry-register/sql" = "sql-sqlite"` in `[bindings]`.
74
+ Choose bindings before initializing stores: changing a retained store's provider
75
+ is rejected and does not copy data. Earlier Core builds require one enabled
76
+ storage provider. The package version alone does not identify multiple-provider
77
+ support; build the matching Core revision when using mixed providers.
78
+
79
+ Install the matching business plugins
80
+ before enabling them: Entry Register 0.4, Auth 0.3, MCP Auth 0.3 and OIDC Auth 0.3.
81
+ Each store owner must be provisioned before Core starts its plugin.
82
+
83
+ ```sh
84
+ .venv/bin/toolframe-postgres run \
85
+ --env-file ./app/.toolframe/postgres-environment.json -- \
86
+ .venv/bin/toolframe-core --home ./app serve
87
+ ```
88
+
89
+ The `run` helper exports the private document as environment variables and replaces
90
+ itself with Core. It removes setup/test administrator variables. Containers can
91
+ inject the same runtime values directly; the provider does not read that file.
92
+
93
+ - [Setup, environment and recovery](docs/operations.md)
94
+ - [SQL and isolation contract](docs/storage-contract.md)
95
+ - [Development and verification](docs/development.md)
96
+ - [Domain glossary](docs/glossary.md) and [architecture decisions](docs/adr/0001-plugin-storage-boundary.md)
97
+
98
+ For release validation and Trusted Publisher setup, see [releasing](docs/releasing.md).
99
+
100
+ ## License
101
+
102
+ Apache-2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
103
+
104
+ For development hooks and contribution rules, see [Contributing](CONTRIBUTING.md).