cinchdb 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 (68) hide show
  1. cinchdb-0.1.0/.gitignore +69 -0
  2. cinchdb-0.1.0/LICENSE +201 -0
  3. cinchdb-0.1.0/PKG-INFO +195 -0
  4. cinchdb-0.1.0/README.md +165 -0
  5. cinchdb-0.1.0/pyproject.toml +86 -0
  6. cinchdb-0.1.0/src/cinchdb/__init__.py +7 -0
  7. cinchdb-0.1.0/src/cinchdb/__main__.py +6 -0
  8. cinchdb-0.1.0/src/cinchdb/api/__init__.py +5 -0
  9. cinchdb-0.1.0/src/cinchdb/api/app.py +76 -0
  10. cinchdb-0.1.0/src/cinchdb/api/auth.py +290 -0
  11. cinchdb-0.1.0/src/cinchdb/api/main.py +137 -0
  12. cinchdb-0.1.0/src/cinchdb/api/routers/__init__.py +25 -0
  13. cinchdb-0.1.0/src/cinchdb/api/routers/auth.py +135 -0
  14. cinchdb-0.1.0/src/cinchdb/api/routers/branches.py +368 -0
  15. cinchdb-0.1.0/src/cinchdb/api/routers/codegen.py +164 -0
  16. cinchdb-0.1.0/src/cinchdb/api/routers/columns.py +290 -0
  17. cinchdb-0.1.0/src/cinchdb/api/routers/data.py +479 -0
  18. cinchdb-0.1.0/src/cinchdb/api/routers/databases.py +177 -0
  19. cinchdb-0.1.0/src/cinchdb/api/routers/projects.py +133 -0
  20. cinchdb-0.1.0/src/cinchdb/api/routers/query.py +156 -0
  21. cinchdb-0.1.0/src/cinchdb/api/routers/tables.py +349 -0
  22. cinchdb-0.1.0/src/cinchdb/api/routers/tenants.py +216 -0
  23. cinchdb-0.1.0/src/cinchdb/api/routers/views.py +219 -0
  24. cinchdb-0.1.0/src/cinchdb/cli/__init__.py +0 -0
  25. cinchdb-0.1.0/src/cinchdb/cli/commands/__init__.py +1 -0
  26. cinchdb-0.1.0/src/cinchdb/cli/commands/branch.py +479 -0
  27. cinchdb-0.1.0/src/cinchdb/cli/commands/codegen.py +176 -0
  28. cinchdb-0.1.0/src/cinchdb/cli/commands/column.py +308 -0
  29. cinchdb-0.1.0/src/cinchdb/cli/commands/database.py +212 -0
  30. cinchdb-0.1.0/src/cinchdb/cli/commands/query.py +136 -0
  31. cinchdb-0.1.0/src/cinchdb/cli/commands/remote.py +144 -0
  32. cinchdb-0.1.0/src/cinchdb/cli/commands/table.py +289 -0
  33. cinchdb-0.1.0/src/cinchdb/cli/commands/tenant.py +173 -0
  34. cinchdb-0.1.0/src/cinchdb/cli/commands/view.py +189 -0
  35. cinchdb-0.1.0/src/cinchdb/cli/handlers/__init__.py +5 -0
  36. cinchdb-0.1.0/src/cinchdb/cli/handlers/codegen_handler.py +189 -0
  37. cinchdb-0.1.0/src/cinchdb/cli/main.py +137 -0
  38. cinchdb-0.1.0/src/cinchdb/cli/utils.py +182 -0
  39. cinchdb-0.1.0/src/cinchdb/config.py +177 -0
  40. cinchdb-0.1.0/src/cinchdb/core/__init__.py +5 -0
  41. cinchdb-0.1.0/src/cinchdb/core/connection.py +175 -0
  42. cinchdb-0.1.0/src/cinchdb/core/database.py +537 -0
  43. cinchdb-0.1.0/src/cinchdb/core/maintenance.py +73 -0
  44. cinchdb-0.1.0/src/cinchdb/core/path_utils.py +153 -0
  45. cinchdb-0.1.0/src/cinchdb/managers/__init__.py +26 -0
  46. cinchdb-0.1.0/src/cinchdb/managers/branch.py +167 -0
  47. cinchdb-0.1.0/src/cinchdb/managers/change_applier.py +414 -0
  48. cinchdb-0.1.0/src/cinchdb/managers/change_comparator.py +194 -0
  49. cinchdb-0.1.0/src/cinchdb/managers/change_tracker.py +182 -0
  50. cinchdb-0.1.0/src/cinchdb/managers/codegen.py +523 -0
  51. cinchdb-0.1.0/src/cinchdb/managers/column.py +579 -0
  52. cinchdb-0.1.0/src/cinchdb/managers/data.py +455 -0
  53. cinchdb-0.1.0/src/cinchdb/managers/merge_manager.py +429 -0
  54. cinchdb-0.1.0/src/cinchdb/managers/query.py +214 -0
  55. cinchdb-0.1.0/src/cinchdb/managers/table.py +383 -0
  56. cinchdb-0.1.0/src/cinchdb/managers/tenant.py +258 -0
  57. cinchdb-0.1.0/src/cinchdb/managers/view.py +252 -0
  58. cinchdb-0.1.0/src/cinchdb/models/__init__.py +27 -0
  59. cinchdb-0.1.0/src/cinchdb/models/base.py +44 -0
  60. cinchdb-0.1.0/src/cinchdb/models/branch.py +26 -0
  61. cinchdb-0.1.0/src/cinchdb/models/change.py +47 -0
  62. cinchdb-0.1.0/src/cinchdb/models/database.py +20 -0
  63. cinchdb-0.1.0/src/cinchdb/models/project.py +20 -0
  64. cinchdb-0.1.0/src/cinchdb/models/table.py +86 -0
  65. cinchdb-0.1.0/src/cinchdb/models/tenant.py +19 -0
  66. cinchdb-0.1.0/src/cinchdb/models/view.py +15 -0
  67. cinchdb-0.1.0/src/cinchdb/utils/__init__.py +15 -0
  68. cinchdb-0.1.0/src/cinchdb/utils/sql_validator.py +137 -0
@@ -0,0 +1,69 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ env/
8
+ venv/
9
+ ENV/
10
+ .env
11
+ .venv
12
+ dist/
13
+ build/
14
+ *.egg-info/
15
+ .pytest_cache/
16
+ .mypy_cache/
17
+ .coverage
18
+ htmlcov/
19
+ .tox/
20
+ .ruff_cache/
21
+
22
+ # Node
23
+ node_modules/
24
+ npm-debug.log*
25
+ yarn-debug.log*
26
+ yarn-error.log*
27
+ .pnpm-debug.log*
28
+ .next/
29
+ out/
30
+ .turbo/
31
+
32
+ # IDE
33
+ .vscode/
34
+ .idea/
35
+ *.swp
36
+ *.swo
37
+ *~
38
+ .DS_Store
39
+
40
+ # CinchDB specific
41
+ .cinchdb/
42
+ *.db
43
+ *.db-wal
44
+ *.db-shm
45
+
46
+ # Claude memory (keep in repo)
47
+ # .claude-memory/
48
+
49
+ # Temporary files
50
+ *.tmp
51
+ *.bak
52
+ .cache/
53
+
54
+ # Documentation build
55
+ docs/.next/
56
+ docs/out/
57
+
58
+ # TypeScript
59
+ *.tsbuildinfo
60
+ sdk/typescript/dist/
61
+
62
+ # Testing
63
+ coverage/
64
+ .nyc_output/
65
+
66
+ # OS
67
+ Thumbs.db
68
+
69
+ site/
cinchdb-0.1.0/LICENSE ADDED
@@ -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.
cinchdb-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,195 @@
1
+ Metadata-Version: 2.4
2
+ Name: cinchdb
3
+ Version: 0.1.0
4
+ Summary: A Git-like SQLite database management system with branching and multi-tenancy
5
+ Project-URL: Homepage, https://github.com/russellromney/cinchdb
6
+ Project-URL: Documentation, https://russellromney.github.io/cinchdb
7
+ Project-URL: Repository, https://github.com/russellromney/cinchdb
8
+ Project-URL: Issues, https://github.com/russellromney/cinchdb/issues
9
+ Author: Russell Romney
10
+ License: MIT
11
+ License-File: LICENSE
12
+ Keywords: branching,database,git,multi-tenant,sqlite
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
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
+ Requires-Python: >=3.10
21
+ Requires-Dist: fastapi>=0.115.0
22
+ Requires-Dist: pydantic>=2.0.0
23
+ Requires-Dist: python-multipart>=0.0.12
24
+ Requires-Dist: requests>=2.28.0
25
+ Requires-Dist: rich>=13.0.0
26
+ Requires-Dist: toml>=0.10.0
27
+ Requires-Dist: typer>=0.9.0
28
+ Requires-Dist: uvicorn>=0.32.0
29
+ Description-Content-Type: text/markdown
30
+
31
+ # CinchDB
32
+
33
+ **Git-like SQLite database management with branching and multi-tenancy**
34
+
35
+ NOTE: CinchDB is in early alpha. This is project to test out an idea. Do not use this in production.
36
+
37
+ CinchDB is for projects that need to isolate data per-tenant [or even per-user](https://turso.tech/blog/give-each-of-your-users-their-own-sqlite-database-b74445f4) and/or want to test out changes to structure safely in branchces. Plus, queries can be super, super fast because data is separated per tenant so it's <data_size>/<n_tenants> instead of <data_size>
38
+
39
+ On a meta level, I made this because I wanted a database structure that I felt comfortable letting AI agents take full control over, safely, and I didn't want to run my own Postgres instance somewhere or pay for it on e.g. Neon - I don't need hyperscaling, I just need super fast queries.
40
+
41
+ Because it's so lightweight and its only dependencies are FastAPI, pydantic, requests, and Typer, it is super cheap to run on a small VM like from [Fly.io](https://fly.io) and I don't need to SSH into it to connect - I can just store an API key in my local projects.
42
+
43
+
44
+ ```bash
45
+ uv pip install cinchdb
46
+
47
+ # Initialize project
48
+ cinch init
49
+
50
+ # Create and query tables
51
+ cinch table create users name:TEXT email:TEXT
52
+ cinch query "SELECT * FROM users"
53
+
54
+ # Git-like branching
55
+ cinch branch create feature
56
+ cinch branch switch feature
57
+ cinch table create products name:TEXT price:REAL
58
+ cinch branch merge-into-main feature
59
+
60
+ # Multi-tenant support
61
+ cinch tenant create customer_a
62
+ cinch query "SELECT * FROM users" --tenant customer_a
63
+
64
+ # API server
65
+ uv pip install cinchdb[server]
66
+ cinch-server serve
67
+
68
+ # Autogenerate Python SDK from database
69
+ cinch codegen generate python cinchdb_models/
70
+ ```
71
+
72
+ ## What is CinchDB?
73
+
74
+ CinchDB combines SQLite with Git-like workflows for database schema management:
75
+
76
+ - **Branch schemas** like code - create feature branches, make changes, merge back
77
+ - **Multi-tenant isolation** - shared schema, isolated data per tenant
78
+ - **Automatic change tracking** - all schema changes tracked and mergeable
79
+ - **Safe structure changes** - change merges happen atomically with zero rollback risk (seriously)
80
+ - **Remote deployment** - FastAPI server with UUID authentication
81
+ - **Type-safe SDK** - Python and TypeScript SDKs with full type safety
82
+ - **API server for remote hosting** - Useful for running many web projects
83
+ - **SDK generation from database schema** - Generate a typesafe SDK from your database models for CRUD operations
84
+
85
+ ## Installation
86
+
87
+ Requires Python 3.10+:
88
+
89
+ ```bash
90
+ pip install cinchdb
91
+ ```
92
+
93
+ ## Quick Start
94
+
95
+ ### CLI Usage
96
+
97
+ ```bash
98
+ # Initialize project
99
+ cinch init my_app
100
+ cd my_app
101
+
102
+ # Create schema on feature branch
103
+ cinch branch create user-system
104
+ cinch table create users username:TEXT email:TEXT
105
+ cinch view create active_users "SELECT * FROM users WHERE created_at > datetime('now', '-30 days')"
106
+
107
+ # Merge to main
108
+ cinch branch merge-into-main user-system
109
+
110
+ # Multi-tenant operations
111
+ cinch tenant create customer_a
112
+ cinch tenant create customer_b
113
+ cinch query "SELECT COUNT(*) FROM users" --tenant customer_a
114
+ ```
115
+
116
+ ### Python SDK
117
+
118
+ ```python
119
+ import cinchdb
120
+ from cinchdb.models import Column
121
+
122
+ # Local connection
123
+ db = cinchdb.connect("myapp")
124
+
125
+ # Create schema
126
+ db.create_table("posts", [
127
+ Column(name="title", type="TEXT",nullable=False),
128
+ Column(name="content", type="TEXT")
129
+ ])
130
+
131
+ # Query data
132
+ results = db.query("SELECT * FROM posts WHERE title LIKE ?", ["%python%"])
133
+
134
+ # CRUD operations
135
+ post_id = db.insert("posts", {"title": "Hello World", "content": "First post"})
136
+ db.update("posts", post_id, {"content": "Updated content"})
137
+ ```
138
+
139
+ ### Remote API
140
+
141
+ ```python
142
+ # Connect to remote API
143
+ db = cinchdb.connect_api("https://api.example.com", "your-api-key", "myapp")
144
+
145
+ # Same interface as local
146
+ results = db.query("SELECT * FROM users")
147
+ user_id = db.insert("users", {"username": "alice", "email": "alice@example.com"})
148
+ ```
149
+
150
+ ## API Server
151
+
152
+ Start the server:
153
+
154
+ ```bash
155
+ cinch-server serve --create-key
156
+ # Creates API key (works after shutdown as well) and starts server on http://localhost:8000
157
+ ```
158
+
159
+ Interactive docs at `/docs`, health check at `/health`.
160
+
161
+ ## Architecture
162
+
163
+ - **Python SDK**: Core functionality (local + remote)
164
+ - **CLI**: Full-featured command-line interface
165
+ - **FastAPI Server**: REST API with authentication
166
+ - **TypeScript SDK**: Browser and Node.js client
167
+
168
+ ## Development
169
+
170
+ ```bash
171
+ git clone https://github.com/russellromney/cinchdb.git
172
+ cd cinchdb
173
+ make install-all
174
+ make test
175
+ ```
176
+
177
+ ## Future
178
+
179
+ Though probably not, perhaps I'll evolve it into something bigger and more full-featured, with things like
180
+ - data backups
181
+ - replication to S3
182
+ - audit access
183
+ - SaaS-like dynamics
184
+ - multi-project hosting
185
+ - auth proxying
186
+ - leader-follower abilities for edge deployment
187
+
188
+
189
+ ## License
190
+
191
+ Apache 2.0 - see [LICENSE](LICENSE)
192
+
193
+ ---
194
+
195
+ **CinchDB** - Database management as easy as version control
@@ -0,0 +1,165 @@
1
+ # CinchDB
2
+
3
+ **Git-like SQLite database management with branching and multi-tenancy**
4
+
5
+ NOTE: CinchDB is in early alpha. This is project to test out an idea. Do not use this in production.
6
+
7
+ CinchDB is for projects that need to isolate data per-tenant [or even per-user](https://turso.tech/blog/give-each-of-your-users-their-own-sqlite-database-b74445f4) and/or want to test out changes to structure safely in branchces. Plus, queries can be super, super fast because data is separated per tenant so it's <data_size>/<n_tenants> instead of <data_size>
8
+
9
+ On a meta level, I made this because I wanted a database structure that I felt comfortable letting AI agents take full control over, safely, and I didn't want to run my own Postgres instance somewhere or pay for it on e.g. Neon - I don't need hyperscaling, I just need super fast queries.
10
+
11
+ Because it's so lightweight and its only dependencies are FastAPI, pydantic, requests, and Typer, it is super cheap to run on a small VM like from [Fly.io](https://fly.io) and I don't need to SSH into it to connect - I can just store an API key in my local projects.
12
+
13
+
14
+ ```bash
15
+ uv pip install cinchdb
16
+
17
+ # Initialize project
18
+ cinch init
19
+
20
+ # Create and query tables
21
+ cinch table create users name:TEXT email:TEXT
22
+ cinch query "SELECT * FROM users"
23
+
24
+ # Git-like branching
25
+ cinch branch create feature
26
+ cinch branch switch feature
27
+ cinch table create products name:TEXT price:REAL
28
+ cinch branch merge-into-main feature
29
+
30
+ # Multi-tenant support
31
+ cinch tenant create customer_a
32
+ cinch query "SELECT * FROM users" --tenant customer_a
33
+
34
+ # API server
35
+ uv pip install cinchdb[server]
36
+ cinch-server serve
37
+
38
+ # Autogenerate Python SDK from database
39
+ cinch codegen generate python cinchdb_models/
40
+ ```
41
+
42
+ ## What is CinchDB?
43
+
44
+ CinchDB combines SQLite with Git-like workflows for database schema management:
45
+
46
+ - **Branch schemas** like code - create feature branches, make changes, merge back
47
+ - **Multi-tenant isolation** - shared schema, isolated data per tenant
48
+ - **Automatic change tracking** - all schema changes tracked and mergeable
49
+ - **Safe structure changes** - change merges happen atomically with zero rollback risk (seriously)
50
+ - **Remote deployment** - FastAPI server with UUID authentication
51
+ - **Type-safe SDK** - Python and TypeScript SDKs with full type safety
52
+ - **API server for remote hosting** - Useful for running many web projects
53
+ - **SDK generation from database schema** - Generate a typesafe SDK from your database models for CRUD operations
54
+
55
+ ## Installation
56
+
57
+ Requires Python 3.10+:
58
+
59
+ ```bash
60
+ pip install cinchdb
61
+ ```
62
+
63
+ ## Quick Start
64
+
65
+ ### CLI Usage
66
+
67
+ ```bash
68
+ # Initialize project
69
+ cinch init my_app
70
+ cd my_app
71
+
72
+ # Create schema on feature branch
73
+ cinch branch create user-system
74
+ cinch table create users username:TEXT email:TEXT
75
+ cinch view create active_users "SELECT * FROM users WHERE created_at > datetime('now', '-30 days')"
76
+
77
+ # Merge to main
78
+ cinch branch merge-into-main user-system
79
+
80
+ # Multi-tenant operations
81
+ cinch tenant create customer_a
82
+ cinch tenant create customer_b
83
+ cinch query "SELECT COUNT(*) FROM users" --tenant customer_a
84
+ ```
85
+
86
+ ### Python SDK
87
+
88
+ ```python
89
+ import cinchdb
90
+ from cinchdb.models import Column
91
+
92
+ # Local connection
93
+ db = cinchdb.connect("myapp")
94
+
95
+ # Create schema
96
+ db.create_table("posts", [
97
+ Column(name="title", type="TEXT",nullable=False),
98
+ Column(name="content", type="TEXT")
99
+ ])
100
+
101
+ # Query data
102
+ results = db.query("SELECT * FROM posts WHERE title LIKE ?", ["%python%"])
103
+
104
+ # CRUD operations
105
+ post_id = db.insert("posts", {"title": "Hello World", "content": "First post"})
106
+ db.update("posts", post_id, {"content": "Updated content"})
107
+ ```
108
+
109
+ ### Remote API
110
+
111
+ ```python
112
+ # Connect to remote API
113
+ db = cinchdb.connect_api("https://api.example.com", "your-api-key", "myapp")
114
+
115
+ # Same interface as local
116
+ results = db.query("SELECT * FROM users")
117
+ user_id = db.insert("users", {"username": "alice", "email": "alice@example.com"})
118
+ ```
119
+
120
+ ## API Server
121
+
122
+ Start the server:
123
+
124
+ ```bash
125
+ cinch-server serve --create-key
126
+ # Creates API key (works after shutdown as well) and starts server on http://localhost:8000
127
+ ```
128
+
129
+ Interactive docs at `/docs`, health check at `/health`.
130
+
131
+ ## Architecture
132
+
133
+ - **Python SDK**: Core functionality (local + remote)
134
+ - **CLI**: Full-featured command-line interface
135
+ - **FastAPI Server**: REST API with authentication
136
+ - **TypeScript SDK**: Browser and Node.js client
137
+
138
+ ## Development
139
+
140
+ ```bash
141
+ git clone https://github.com/russellromney/cinchdb.git
142
+ cd cinchdb
143
+ make install-all
144
+ make test
145
+ ```
146
+
147
+ ## Future
148
+
149
+ Though probably not, perhaps I'll evolve it into something bigger and more full-featured, with things like
150
+ - data backups
151
+ - replication to S3
152
+ - audit access
153
+ - SaaS-like dynamics
154
+ - multi-project hosting
155
+ - auth proxying
156
+ - leader-follower abilities for edge deployment
157
+
158
+
159
+ ## License
160
+
161
+ Apache 2.0 - see [LICENSE](LICENSE)
162
+
163
+ ---
164
+
165
+ **CinchDB** - Database management as easy as version control