hoie-database 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.
- hoie_database-0.1.0/Cargo.toml +44 -0
- hoie_database-0.1.0/LICENSE +202 -0
- hoie_database-0.1.0/PKG-INFO +111 -0
- hoie_database-0.1.0/README.md +92 -0
- hoie_database-0.1.0/bindings/Cargo.lock +612 -0
- hoie_database-0.1.0/bindings/Cargo.toml +31 -0
- hoie_database-0.1.0/bindings/frames/Cargo.toml +17 -0
- hoie_database-0.1.0/bindings/frames/src/lib.rs +171 -0
- hoie_database-0.1.0/bindings/python/.gitignore +6 -0
- hoie_database-0.1.0/bindings/python/Cargo.toml +24 -0
- hoie_database-0.1.0/bindings/python/README.md +92 -0
- hoie_database-0.1.0/bindings/python/src/lib.rs +114 -0
- hoie_database-0.1.0/bindings/python/tests/__init__.py +0 -0
- hoie_database-0.1.0/bindings/python/tests/test_embedded.py +123 -0
- hoie_database-0.1.0/clients/rust/Cargo.toml +28 -0
- hoie_database-0.1.0/clients/rust/LICENSE +202 -0
- hoie_database-0.1.0/clients/rust/README.md +35 -0
- hoie_database-0.1.0/clients/rust/src/client.rs +1122 -0
- hoie_database-0.1.0/clients/rust/src/config.rs +245 -0
- hoie_database-0.1.0/clients/rust/src/conn.rs +750 -0
- hoie_database-0.1.0/clients/rust/src/connector.rs +136 -0
- hoie_database-0.1.0/clients/rust/src/lib.rs +52 -0
- hoie_database-0.1.0/clients/rust/src/local.rs +60 -0
- hoie_database-0.1.0/clients/rust/src/row.rs +236 -0
- hoie_database-0.1.0/clients/rust/src/tls.rs +68 -0
- hoie_database-0.1.0/engine/Cargo.toml +16 -0
- hoie_database-0.1.0/engine/LICENSE +202 -0
- hoie_database-0.1.0/engine/src/archive.rs +661 -0
- hoie_database-0.1.0/engine/src/blob.rs +162 -0
- hoie_database-0.1.0/engine/src/btree.rs +1489 -0
- hoie_database-0.1.0/engine/src/cache.rs +217 -0
- hoie_database-0.1.0/engine/src/catalog.rs +797 -0
- hoie_database-0.1.0/engine/src/db.rs +1950 -0
- hoie_database-0.1.0/engine/src/dump.rs +382 -0
- hoie_database-0.1.0/engine/src/engine.rs +1121 -0
- hoie_database-0.1.0/engine/src/error.rs +66 -0
- hoie_database-0.1.0/engine/src/eval.rs +1773 -0
- hoie_database-0.1.0/engine/src/exec.rs +1088 -0
- hoie_database-0.1.0/engine/src/fts.rs +1570 -0
- hoie_database-0.1.0/engine/src/keys.rs +268 -0
- hoie_database-0.1.0/engine/src/lib.rs +24 -0
- hoie_database-0.1.0/engine/src/near.rs +334 -0
- hoie_database-0.1.0/engine/src/page.rs +195 -0
- hoie_database-0.1.0/engine/src/plan.rs +874 -0
- hoie_database-0.1.0/engine/src/row.rs +1025 -0
- hoie_database-0.1.0/engine/src/store.rs +1666 -0
- hoie_database-0.1.0/engine/src/text.rs +804 -0
- hoie_database-0.1.0/engine/src/vfs.rs +1176 -0
- hoie_database-0.1.0/engine/src/wal.rs +974 -0
- hoie_database-0.1.0/engine/src/write.rs +1659 -0
- hoie_database-0.1.0/protocol/Cargo.toml +14 -0
- hoie_database-0.1.0/protocol/LICENSE +202 -0
- hoie_database-0.1.0/protocol/src/codec.rs +1110 -0
- hoie_database-0.1.0/protocol/src/decimal.rs +395 -0
- hoie_database-0.1.0/protocol/src/error.rs +152 -0
- hoie_database-0.1.0/protocol/src/expr.rs +808 -0
- hoie_database-0.1.0/protocol/src/lib.rs +14 -0
- hoie_database-0.1.0/protocol/src/message.rs +1119 -0
- hoie_database-0.1.0/protocol/src/query.rs +758 -0
- hoie_database-0.1.0/protocol/src/rights.rs +130 -0
- hoie_database-0.1.0/protocol/src/schema.rs +333 -0
- hoie_database-0.1.0/protocol/src/time.rs +247 -0
- hoie_database-0.1.0/protocol/src/value.rs +883 -0
- hoie_database-0.1.0/pyproject.toml +33 -0
- hoie_database-0.1.0/python/hoie_database/__init__.py +106 -0
- hoie_database-0.1.0/python/hoie_database/_native.pyi +16 -0
- hoie_database-0.1.0/python/hoie_database/py.typed +0 -0
- hoie_database-0.1.0/server/Cargo.toml +40 -0
- hoie_database-0.1.0/server/LICENSE +202 -0
- hoie_database-0.1.0/server/README.md +57 -0
- hoie_database-0.1.0/server/src/access.rs +253 -0
- hoie_database-0.1.0/server/src/embedded.rs +588 -0
- hoie_database-0.1.0/server/src/gate.rs +330 -0
- hoie_database-0.1.0/server/src/lib.rs +594 -0
- hoie_database-0.1.0/server/src/main.rs +371 -0
- hoie_database-0.1.0/server/src/memory/pages.rs +333 -0
- hoie_database-0.1.0/server/src/memory.rs +180 -0
- hoie_database-0.1.0/server/src/session/budget.rs +240 -0
- hoie_database-0.1.0/server/src/session/load.rs +87 -0
- hoie_database-0.1.0/server/src/session/role.rs +78 -0
- hoie_database-0.1.0/server/src/session.rs +2310 -0
- hoie_database-0.1.0/server/src/tls.rs +209 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
[workspace]
|
|
2
|
+
resolver = "2"
|
|
3
|
+
members = ["protocol", "engine", "clients/rust", "server", "bench"]
|
|
4
|
+
|
|
5
|
+
[workspace.package]
|
|
6
|
+
version = "0.1.0"
|
|
7
|
+
edition = "2021"
|
|
8
|
+
rust-version = "1.89"
|
|
9
|
+
publish = false
|
|
10
|
+
|
|
11
|
+
# Every dependency runs inside the process that holds everyone's data, so
|
|
12
|
+
# the list is kept to what the standard library lacks: an async runtime for
|
|
13
|
+
# the network side, a CRC for page and log checksums, and JSON for the
|
|
14
|
+
# columns that hold it. TLS, for clients on other hosts, is in a build
|
|
15
|
+
# only by the `tls` feature of the server and of the client: rustls with
|
|
16
|
+
# nothing it can do without (TLS 1.3 alone, no logging, and `ring` for
|
|
17
|
+
# the ciphers, the smaller of the two libraries rustls is built on).
|
|
18
|
+
[workspace.dependencies]
|
|
19
|
+
tokio = { version = "1", default-features = false }
|
|
20
|
+
crc32fast = "1"
|
|
21
|
+
serde_json = { version = "1", features = ["preserve_order", "float_roundtrip"] }
|
|
22
|
+
rustls = { version = "0.23", default-features = false, features = ["ring", "std"] }
|
|
23
|
+
tokio-rustls = { version = "0.26", default-features = false }
|
|
24
|
+
|
|
25
|
+
# One unit, optimized whole: with four units and thin LTO, each unit kept
|
|
26
|
+
# its own copy of whatever generic code it used (half a megabyte of the
|
|
27
|
+
# server was second and later copies of the same functions), and calls
|
|
28
|
+
# between the crates were not inlined across them. Built this way the
|
|
29
|
+
# server is a quarter smaller and nothing it does is slower
|
|
30
|
+
# (`docs/PERFORMANCE.md`, "Footprint"). It costs a release build half as
|
|
31
|
+
# long again; the tests build without it.
|
|
32
|
+
[profile.release]
|
|
33
|
+
opt-level = 3
|
|
34
|
+
lto = "fat"
|
|
35
|
+
codegen-units = 1
|
|
36
|
+
strip = true
|
|
37
|
+
panic = "unwind"
|
|
38
|
+
|
|
39
|
+
# The storage tests run thousands of simulated crashes; unoptimized, the
|
|
40
|
+
# page and checksum code makes them take minutes.
|
|
41
|
+
[profile.dev.package.hoie-database-engine]
|
|
42
|
+
opt-level = 2
|
|
43
|
+
[profile.dev.package.crc32fast]
|
|
44
|
+
opt-level = 3
|
|
@@ -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,111 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hoie-database
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Classifier: Programming Language :: Python :: 3
|
|
5
|
+
Classifier: Programming Language :: Rust
|
|
6
|
+
Classifier: Topic :: Database :: Database Engines/Servers
|
|
7
|
+
Classifier: Typing :: Typed
|
|
8
|
+
Requires-Dist: hoie-database-client~=0.1.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Summary: A small database with a typed client and no SQL, held in the application's process
|
|
11
|
+
Keywords: database,embedded
|
|
12
|
+
License-Expression: Apache-2.0
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
15
|
+
Project-URL: Homepage, https://github.com/hoiekim/database/tree/main/bindings/python#readme
|
|
16
|
+
Project-URL: Issues, https://github.com/hoiekim/database/issues
|
|
17
|
+
Project-URL: Repository, https://github.com/hoiekim/database
|
|
18
|
+
|
|
19
|
+
# hoie-database
|
|
20
|
+
|
|
21
|
+
A small database with a typed client and no SQL, held in the
|
|
22
|
+
application's own process, where an application would otherwise embed
|
|
23
|
+
SQLite. The client is the one of `hoie-database-client`, which connects to the
|
|
24
|
+
database's server; here it is given a data directory the application
|
|
25
|
+
holds itself, and nothing else changes: the same statements,
|
|
26
|
+
transactions and answers, and a commit on disk before it is answered.
|
|
27
|
+
Python 3.9 or later.
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
pip install hoie-database
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
import hoie_database
|
|
35
|
+
from hoie_database import ColumnDef, Insert, Query, TableDef, Type
|
|
36
|
+
|
|
37
|
+
with hoie_database.open("./data") as here: # the directory a server would be given
|
|
38
|
+
db = here.database("shop") # a ``Client`` of hoie-database-client; the database is created if it is not there
|
|
39
|
+
db.create_table_if_not_exists(
|
|
40
|
+
TableDef("items").column(ColumnDef("id", Type.INT)).column(ColumnDef("name", Type.TEXT)).primary_key(["id"])
|
|
41
|
+
)
|
|
42
|
+
db.insert(Insert.into("items").set("id", 1).set("name", "nut"))
|
|
43
|
+
items = db.query(Query.table("items"))
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The package exports everything `hoie_database_client` does, and `hoie_database.open`
|
|
47
|
+
(which `from hoie_database import *` leaves out, so as not to hide the built-in
|
|
48
|
+
`open`). The client's README and `docs/CLIENT.md` in the repository
|
|
49
|
+
describe the vocabulary; this package changes only where the client's
|
|
50
|
+
requests go.
|
|
51
|
+
|
|
52
|
+
## The directory
|
|
53
|
+
|
|
54
|
+
- `hoie_database.open(path)` opens the databases in the directory, creating it
|
|
55
|
+
if it is not there and recovering each database as a server does when
|
|
56
|
+
it starts.
|
|
57
|
+
- `here.database(name, *, pool_size=None, statement_timeout=None,
|
|
58
|
+
lock_wait=None)` is a client of the database `name`, which is created
|
|
59
|
+
if there is none; the settings are a `Config`'s. The client is of the
|
|
60
|
+
database as it is now: if the database is dropped, or restored over,
|
|
61
|
+
the client is told so with `UNAVAILABLE`; ask again.
|
|
62
|
+
- `here.admin()` is a client on no database, for creating, dropping and
|
|
63
|
+
listing databases and restoring.
|
|
64
|
+
- `here.close()` writes a checkpoint of every database and closes the
|
|
65
|
+
clients made from it; so does the end of a `with` block. Not calling it
|
|
66
|
+
loses nothing: what was committed is in the log, and the next opening
|
|
67
|
+
replays it, as after a crash.
|
|
68
|
+
|
|
69
|
+
## What differs from a server
|
|
70
|
+
|
|
71
|
+
- **One process has a directory at a time.** While this one holds it,
|
|
72
|
+
another process, or a server, cannot open it, and `open` raises
|
|
73
|
+
`OSError`. A server may serve the directory afterwards, and it may be
|
|
74
|
+
held again after that.
|
|
75
|
+
- **Whoever holds the directory is its administrator.** There are no
|
|
76
|
+
passwords to give and no roles to connect as. A database created here
|
|
77
|
+
has no password; a server started on the directory later serves it to
|
|
78
|
+
the administrator alone until it is given one.
|
|
79
|
+
- **A dump is taken from a server** (`database dump`), not through
|
|
80
|
+
`admin.dump`, which is refused.
|
|
81
|
+
- **A transaction left open is never timed out.** It is the
|
|
82
|
+
application's own to end.
|
|
83
|
+
|
|
84
|
+
Each of the client's connections is a connection of the directory in
|
|
85
|
+
place of a socket: the client writes the frames it would write to a
|
|
86
|
+
server, and the native module answers them as the server would, in this
|
|
87
|
+
process, on threads of its own. A call blocks its thread with the
|
|
88
|
+
interpreter's lock let go of, so other threads run meanwhile. What it
|
|
89
|
+
spares an application is a server to run. The Rust crate `hoie-database` spares
|
|
90
|
+
a request the encoding and the other thread as well: a query on its own
|
|
91
|
+
is answered on the thread that asked.
|
|
92
|
+
|
|
93
|
+
## Platforms
|
|
94
|
+
|
|
95
|
+
Wheels are built for Linux (manylinux, x86-64 and ARM64) and for macOS
|
|
96
|
+
(x86-64 and ARM64), each one for every Python from 3.9 on. Elsewhere pip
|
|
97
|
+
builds the module from the source distribution, which needs Rust.
|
|
98
|
+
|
|
99
|
+
## Building and testing
|
|
100
|
+
|
|
101
|
+
The module is Rust, in `src/` (with `../frames`, which the Node module
|
|
102
|
+
shares); `python/hoie_database` is the Python around it.
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
cd bindings/python
|
|
106
|
+
pip install maturin
|
|
107
|
+
maturin build --release --out dist && pip install --no-deps dist/hoie_database-*.whl
|
|
108
|
+
PYTHONPATH=../../clients/python python -m unittest discover -s tests -t . # tests/: what a directory held in this process does that a server does not
|
|
109
|
+
cd ../../clients/python && DATABASE_TEST_EMBEDDED=1 python -m unittest discover -s tests -t . # the client's own suite, against a directory held in its process
|
|
110
|
+
```
|
|
111
|
+
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# hoie-database
|
|
2
|
+
|
|
3
|
+
A small database with a typed client and no SQL, held in the
|
|
4
|
+
application's own process, where an application would otherwise embed
|
|
5
|
+
SQLite. The client is the one of `hoie-database-client`, which connects to the
|
|
6
|
+
database's server; here it is given a data directory the application
|
|
7
|
+
holds itself, and nothing else changes: the same statements,
|
|
8
|
+
transactions and answers, and a commit on disk before it is answered.
|
|
9
|
+
Python 3.9 or later.
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pip install hoie-database
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
import hoie_database
|
|
17
|
+
from hoie_database import ColumnDef, Insert, Query, TableDef, Type
|
|
18
|
+
|
|
19
|
+
with hoie_database.open("./data") as here: # the directory a server would be given
|
|
20
|
+
db = here.database("shop") # a ``Client`` of hoie-database-client; the database is created if it is not there
|
|
21
|
+
db.create_table_if_not_exists(
|
|
22
|
+
TableDef("items").column(ColumnDef("id", Type.INT)).column(ColumnDef("name", Type.TEXT)).primary_key(["id"])
|
|
23
|
+
)
|
|
24
|
+
db.insert(Insert.into("items").set("id", 1).set("name", "nut"))
|
|
25
|
+
items = db.query(Query.table("items"))
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The package exports everything `hoie_database_client` does, and `hoie_database.open`
|
|
29
|
+
(which `from hoie_database import *` leaves out, so as not to hide the built-in
|
|
30
|
+
`open`). The client's README and `docs/CLIENT.md` in the repository
|
|
31
|
+
describe the vocabulary; this package changes only where the client's
|
|
32
|
+
requests go.
|
|
33
|
+
|
|
34
|
+
## The directory
|
|
35
|
+
|
|
36
|
+
- `hoie_database.open(path)` opens the databases in the directory, creating it
|
|
37
|
+
if it is not there and recovering each database as a server does when
|
|
38
|
+
it starts.
|
|
39
|
+
- `here.database(name, *, pool_size=None, statement_timeout=None,
|
|
40
|
+
lock_wait=None)` is a client of the database `name`, which is created
|
|
41
|
+
if there is none; the settings are a `Config`'s. The client is of the
|
|
42
|
+
database as it is now: if the database is dropped, or restored over,
|
|
43
|
+
the client is told so with `UNAVAILABLE`; ask again.
|
|
44
|
+
- `here.admin()` is a client on no database, for creating, dropping and
|
|
45
|
+
listing databases and restoring.
|
|
46
|
+
- `here.close()` writes a checkpoint of every database and closes the
|
|
47
|
+
clients made from it; so does the end of a `with` block. Not calling it
|
|
48
|
+
loses nothing: what was committed is in the log, and the next opening
|
|
49
|
+
replays it, as after a crash.
|
|
50
|
+
|
|
51
|
+
## What differs from a server
|
|
52
|
+
|
|
53
|
+
- **One process has a directory at a time.** While this one holds it,
|
|
54
|
+
another process, or a server, cannot open it, and `open` raises
|
|
55
|
+
`OSError`. A server may serve the directory afterwards, and it may be
|
|
56
|
+
held again after that.
|
|
57
|
+
- **Whoever holds the directory is its administrator.** There are no
|
|
58
|
+
passwords to give and no roles to connect as. A database created here
|
|
59
|
+
has no password; a server started on the directory later serves it to
|
|
60
|
+
the administrator alone until it is given one.
|
|
61
|
+
- **A dump is taken from a server** (`database dump`), not through
|
|
62
|
+
`admin.dump`, which is refused.
|
|
63
|
+
- **A transaction left open is never timed out.** It is the
|
|
64
|
+
application's own to end.
|
|
65
|
+
|
|
66
|
+
Each of the client's connections is a connection of the directory in
|
|
67
|
+
place of a socket: the client writes the frames it would write to a
|
|
68
|
+
server, and the native module answers them as the server would, in this
|
|
69
|
+
process, on threads of its own. A call blocks its thread with the
|
|
70
|
+
interpreter's lock let go of, so other threads run meanwhile. What it
|
|
71
|
+
spares an application is a server to run. The Rust crate `hoie-database` spares
|
|
72
|
+
a request the encoding and the other thread as well: a query on its own
|
|
73
|
+
is answered on the thread that asked.
|
|
74
|
+
|
|
75
|
+
## Platforms
|
|
76
|
+
|
|
77
|
+
Wheels are built for Linux (manylinux, x86-64 and ARM64) and for macOS
|
|
78
|
+
(x86-64 and ARM64), each one for every Python from 3.9 on. Elsewhere pip
|
|
79
|
+
builds the module from the source distribution, which needs Rust.
|
|
80
|
+
|
|
81
|
+
## Building and testing
|
|
82
|
+
|
|
83
|
+
The module is Rust, in `src/` (with `../frames`, which the Node module
|
|
84
|
+
shares); `python/hoie_database` is the Python around it.
|
|
85
|
+
|
|
86
|
+
```sh
|
|
87
|
+
cd bindings/python
|
|
88
|
+
pip install maturin
|
|
89
|
+
maturin build --release --out dist && pip install --no-deps dist/hoie_database-*.whl
|
|
90
|
+
PYTHONPATH=../../clients/python python -m unittest discover -s tests -t . # tests/: what a directory held in this process does that a server does not
|
|
91
|
+
cd ../../clients/python && DATABASE_TEST_EMBEDDED=1 python -m unittest discover -s tests -t . # the client's own suite, against a directory held in its process
|
|
92
|
+
```
|