zypherdb 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 (117) hide show
  1. zypherdb-0.1.0/CHANGELOG.md +27 -0
  2. zypherdb-0.1.0/LICENSE +201 -0
  3. zypherdb-0.1.0/PKG-INFO +171 -0
  4. zypherdb-0.1.0/README.md +134 -0
  5. zypherdb-0.1.0/THIRD_PARTY_NOTICES.md +109 -0
  6. zypherdb-0.1.0/build.zig +195 -0
  7. zypherdb-0.1.0/build.zig.zon +16 -0
  8. zypherdb-0.1.0/include/zypherdb.h +136 -0
  9. zypherdb-0.1.0/pyproject.toml +61 -0
  10. zypherdb-0.1.0/python/native/module.zig +1070 -0
  11. zypherdb-0.1.0/python/native/python.h +5 -0
  12. zypherdb-0.1.0/python/native/temporals.zig +321 -0
  13. zypherdb-0.1.0/python/zypherdb/__init__.py +54 -0
  14. zypherdb-0.1.0/python/zypherdb/_engine.py +55 -0
  15. zypherdb-0.1.0/python/zypherdb/db.py +324 -0
  16. zypherdb-0.1.0/python/zypherdb/entities.py +82 -0
  17. zypherdb-0.1.0/python/zypherdb/errors.py +83 -0
  18. zypherdb-0.1.0/python/zypherdb/temporal.py +63 -0
  19. zypherdb-0.1.0/src/c_api.zig +944 -0
  20. zypherdb-0.1.0/src/diagnostics.zig +89 -0
  21. zypherdb-0.1.0/src/execution/Executor.zig +317 -0
  22. zypherdb-0.1.0/src/execution/aggregation.zig +420 -0
  23. zypherdb-0.1.0/src/execution/bindings.zig +142 -0
  24. zypherdb-0.1.0/src/execution/clauses.zig +43 -0
  25. zypherdb-0.1.0/src/execution/comparison.zig +119 -0
  26. zypherdb-0.1.0/src/execution/entities.zig +82 -0
  27. zypherdb-0.1.0/src/execution/expressions.zig +595 -0
  28. zypherdb-0.1.0/src/execution/functions.zig +678 -0
  29. zypherdb-0.1.0/src/execution/load_csv.zig +120 -0
  30. zypherdb-0.1.0/src/execution/operators.zig +419 -0
  31. zypherdb-0.1.0/src/execution/pattern_matching.zig +482 -0
  32. zypherdb-0.1.0/src/execution/procedures.zig +210 -0
  33. zypherdb-0.1.0/src/execution/profiling.zig +139 -0
  34. zypherdb-0.1.0/src/execution/projection.zig +421 -0
  35. zypherdb-0.1.0/src/execution/schema.zig +238 -0
  36. zypherdb-0.1.0/src/execution/shortest_paths.zig +192 -0
  37. zypherdb-0.1.0/src/execution/temporal_functions.zig +468 -0
  38. zypherdb-0.1.0/src/execution/writes.zig +361 -0
  39. zypherdb-0.1.0/src/planning/Plan.zig +271 -0
  40. zypherdb-0.1.0/src/planning/builder.zig +419 -0
  41. zypherdb-0.1.0/src/planning/explain.zig +527 -0
  42. zypherdb-0.1.0/src/planning/expression_program.zig +156 -0
  43. zypherdb-0.1.0/src/planning/patterns.zig +384 -0
  44. zypherdb-0.1.0/src/planning/scope.zig +33 -0
  45. zypherdb-0.1.0/src/planning/statistics.zig +74 -0
  46. zypherdb-0.1.0/src/query/ast.zig +490 -0
  47. zypherdb-0.1.0/src/query/call_parser.zig +76 -0
  48. zypherdb-0.1.0/src/query/expression_parser.zig +581 -0
  49. zypherdb-0.1.0/src/query/lexer.zig +371 -0
  50. zypherdb-0.1.0/src/query/parser.zig +1005 -0
  51. zypherdb-0.1.0/src/query/printer.zig +465 -0
  52. zypherdb-0.1.0/src/query/procedures.zig +77 -0
  53. zypherdb-0.1.0/src/query/schema_parser.zig +322 -0
  54. zypherdb-0.1.0/src/query/semantics.zig +799 -0
  55. zypherdb-0.1.0/src/root.zig +125 -0
  56. zypherdb-0.1.0/src/sequence_algorithms.zig +271 -0
  57. zypherdb-0.1.0/src/statement/Cache.zig +71 -0
  58. zypherdb-0.1.0/src/statement/Statement.zig +224 -0
  59. zypherdb-0.1.0/src/storage/constraints.zig +95 -0
  60. zypherdb-0.1.0/src/storage/engine/contract.zig +104 -0
  61. zypherdb-0.1.0/src/storage/engine/faulty.zig +253 -0
  62. zypherdb-0.1.0/src/storage/engine/lmdb.zig +211 -0
  63. zypherdb-0.1.0/src/storage/engine/lmdb_bindings.zig +83 -0
  64. zypherdb-0.1.0/src/storage/engine/mdbx.zig +225 -0
  65. zypherdb-0.1.0/src/storage/engine/mdbx_bindings.zig +121 -0
  66. zypherdb-0.1.0/src/storage/engine.zig +26 -0
  67. zypherdb-0.1.0/src/storage/fulltext.zig +234 -0
  68. zypherdb-0.1.0/src/storage/fulltext_postings.zig +414 -0
  69. zypherdb-0.1.0/src/storage/fulltext_search.zig +343 -0
  70. zypherdb-0.1.0/src/storage/graph.zig +1128 -0
  71. zypherdb-0.1.0/src/storage/integrity.zig +445 -0
  72. zypherdb-0.1.0/src/storage/integrity_fulltext.zig +173 -0
  73. zypherdb-0.1.0/src/storage/key_encoding.zig +180 -0
  74. zypherdb-0.1.0/src/storage/key_value_store.zig +560 -0
  75. zypherdb-0.1.0/src/storage/layout.zig +292 -0
  76. zypherdb-0.1.0/src/storage/node_record.zig +228 -0
  77. zypherdb-0.1.0/src/storage/property_indexes.zig +236 -0
  78. zypherdb-0.1.0/src/storage/value_encoding.zig +332 -0
  79. zypherdb-0.1.0/src/temporal/calendar.zig +149 -0
  80. zypherdb-0.1.0/src/temporal/durations.zig +347 -0
  81. zypherdb-0.1.0/src/temporal/parse.zig +323 -0
  82. zypherdb-0.1.0/src/temporal/selection.zig +297 -0
  83. zypherdb-0.1.0/src/temporal/types.zig +268 -0
  84. zypherdb-0.1.0/src/temporal/zones.zig +290 -0
  85. zypherdb-0.1.0/src/text/analyzer.zig +123 -0
  86. zypherdb-0.1.0/src/text/csv.zig +136 -0
  87. zypherdb-0.1.0/src/text/query.zig +221 -0
  88. zypherdb-0.1.0/src/text/regex.zig +779 -0
  89. zypherdb-0.1.0/src/text/snowball.zig +198 -0
  90. zypherdb-0.1.0/src/text/stem_english.zig +363 -0
  91. zypherdb-0.1.0/src/text/stem_spanish.zig +393 -0
  92. zypherdb-0.1.0/src/text/stop_words.zig +140 -0
  93. zypherdb-0.1.0/src/text/unicode.zig +111 -0
  94. zypherdb-0.1.0/src/text/unicode_tables.zig +3691 -0
  95. zypherdb-0.1.0/src/value.zig +432 -0
  96. zypherdb-0.1.0/tools/build_backend/zypherdb_build.py +304 -0
  97. zypherdb-0.1.0/vendor/libmdbx/COPYRIGHT +159 -0
  98. zypherdb-0.1.0/vendor/libmdbx/LICENSE +177 -0
  99. zypherdb-0.1.0/vendor/libmdbx/NOTICE +43 -0
  100. zypherdb-0.1.0/vendor/libmdbx/PATCHES.md +30 -0
  101. zypherdb-0.1.0/vendor/libmdbx/VERSION.json +1 -0
  102. zypherdb-0.1.0/vendor/libmdbx/mdbx-internals.h +4013 -0
  103. zypherdb-0.1.0/vendor/libmdbx/mdbx.c +42804 -0
  104. zypherdb-0.1.0/vendor/libmdbx/mdbx.h +7683 -0
  105. zypherdb-0.1.0/vendor/libmdbx/ntdll.def +1247 -0
  106. zypherdb-0.1.0/vendor/lmdb/COPYRIGHT +20 -0
  107. zypherdb-0.1.0/vendor/lmdb/LICENSE +47 -0
  108. zypherdb-0.1.0/vendor/lmdb/lmdb.h +1934 -0
  109. zypherdb-0.1.0/vendor/lmdb/mdb.c +12909 -0
  110. zypherdb-0.1.0/vendor/lmdb/midl.c +452 -0
  111. zypherdb-0.1.0/vendor/lmdb/midl.h +210 -0
  112. zypherdb-0.1.0/vendor/shims/sys/cachectl.h +5 -0
  113. zypherdb-0.1.0/vendor/tzdata/LICENSE +16 -0
  114. zypherdb-0.1.0/vendor/tzdata/LICENSE_APACHE +201 -0
  115. zypherdb-0.1.0/vendor/tzdata/README.md +26 -0
  116. zypherdb-0.1.0/vendor/tzdata/tzdata.bin +0 -0
  117. zypherdb-0.1.0/vendor/tzdata/tzdata.zig +613 -0
@@ -0,0 +1,27 @@
1
+ # Changelog
2
+
3
+ ## Unreleased
4
+
5
+ ## 0.1.0 — 2026-10-28
6
+
7
+ The first release.
8
+
9
+ ### Added
10
+
11
+ - **openCypher**: reading and writing clauses, variable-length and shortest paths, subqueries,
12
+ aggregation, temporal types and functions, `LOAD CSV`, `EXPLAIN` and `PROFILE`; the whole
13
+ openCypher TCK's positive scenarios pass (see `tests/tck/REPORT.md`).
14
+ - **Indexes and constraints with Neo4j's syntax**: `CREATE INDEX` on node and relationship
15
+ properties (a field of a document property too), read by equality and range predicates;
16
+ `CREATE CONSTRAINT ... REQUIRE ... IS UNIQUE`; `SHOW INDEXES`, `SHOW CONSTRAINTS` and `DROP`.
17
+ - **Full-text search** with Neo4j's syntax: English and Spanish analyzers (Snowball stemmers), BM25
18
+ scores.
19
+ - **Storage** on LMDB (the default) or libmdbx, chosen at build time: transactions, crash safety,
20
+ readers that never wait, several processes on one database. Storage format 1.
21
+ - **Time zones** from the IANA database, embedded: no system time-zone data needed.
22
+ - **Prepared statements** and a cache of the statements `query` prepares.
23
+ - **Embeddings**: a C ABI (`include/zypherdb.h`) and a Python package (`import zypherdb`). Wheels
24
+ for Python 3.10 and later (one abi3 wheel per platform) on Linux x86_64 and aarch64
25
+ (manylinux2014), macOS arm64 and x86_64, and Windows x86_64.
26
+ - **An integrity checker** (`check()`), and the test machinery behind it: storage, query, fault and
27
+ crash fuzzers, snapshot tests and pair assertions (see `docs/guide/testing.md`).
zypherdb-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 Derivative
95
+ 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, excluding
103
+ those notices that do not pertain to any part of the Derivative
104
+ 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 of
111
+ the following places: within a NOTICE text file distributed as
112
+ 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 do
117
+ not modify the License. You may add Your own attribution notices
118
+ within Derivative Works that You distribute, alongside or as an
119
+ addendum to the NOTICE text from the Work, provided that such
120
+ additional attribution notices cannot be construed as modifying
121
+ 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 2026 Alberto Casado
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.
@@ -0,0 +1,171 @@
1
+ Metadata-Version: 2.4
2
+ Name: zypherdb
3
+ Version: 0.1.0
4
+ Summary: Python bindings for ZypherDB, an embedded graph database (openCypher on LMDB or libmdbx)
5
+ Requires-Python: >=3.10
6
+ License-Expression: Apache-2.0
7
+ License-File: LICENSE
8
+ License-File: THIRD_PARTY_NOTICES.md
9
+ License-File: vendor/lmdb/LICENSE
10
+ License-File: vendor/lmdb/COPYRIGHT
11
+ License-File: vendor/tzdata/LICENSE
12
+ License-File: vendor/tzdata/LICENSE_APACHE
13
+ Author: Alberto Casado
14
+ Keywords: graph database,graph-database,embedded database,embedded-database,opencypher,cypher,lmdb,libmdbx,zig,full-text search,access control
15
+ Classifier: Development Status :: 3 - Alpha
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Topic :: Database
18
+ Classifier: Topic :: Database :: Database Engines/Servers
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Programming Language :: Zig
26
+ Classifier: Operating System :: POSIX :: Linux
27
+ Classifier: Operating System :: MacOS
28
+ Project-URL: Homepage, https://github.com/acasadom/zypherdb
29
+ Project-URL: Repository, https://github.com/acasadom/zypherdb
30
+ Project-URL: Documentation, https://acasadom.github.io/zypherdb/
31
+ Project-URL: Issues, https://github.com/acasadom/zypherdb/issues
32
+ Project-URL: Changelog, https://github.com/acasadom/zypherdb/blob/main/CHANGELOG.md
33
+ Requires-Dist: tzdata; sys_platform == 'win32'
34
+ Provides-Extra: dev
35
+ Requires-Dist: pytest>=8; extra == "dev"
36
+ Description-Content-Type: text/markdown
37
+
38
+ # ZypherDB
39
+
40
+ *An embedded graph database that speaks openCypher.*
41
+
42
+ [![CI](https://github.com/acasadom/zypherdb/actions/workflows/ci.yml/badge.svg)](https://github.com/acasadom/zypherdb/actions/workflows/ci.yml)
43
+ [![License: Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/acasadom/zypherdb/blob/main/LICENSE)
44
+ ![Python](https://img.shields.io/badge/python-3.10%2B-blue)
45
+ [![Docs](https://img.shields.io/badge/docs-acasadom.github.io%2Fzypherdb-blue)](https://acasadom.github.io/zypherdb/)
46
+
47
+ ZypherDB is to graphs what SQLite is to tables: a database that lives inside your process and
48
+ keeps its data in a directory, with no server to run. You store nodes and relationships and
49
+ query them in **openCypher**, the language of Neo4j. Several processes can share a database, and
50
+ a crash never leaves it half-written. The engine is written in Zig, on LMDB.
51
+
52
+ ## Install
53
+
54
+ ```bash
55
+ pip install zypherdb
56
+ ```
57
+
58
+ Python 3.10 or later, on Linux (x86_64, aarch64), macOS (Apple silicon, Intel) and Windows
59
+ (x86_64). No dependencies (on Windows, only `tzdata`).
60
+
61
+ ## A first look
62
+
63
+ Who may open a door, through groups nested to any depth, and at what times:
64
+
65
+ ```python
66
+ from zypherdb import Database
67
+
68
+ db = Database("lab.db") # a directory, created if missing
69
+
70
+ db.query("CREATE INDEX FOR (d:Door) ON (d.name)") # doors are looked up by name
71
+ db.query("""
72
+ CREATE (ana:Person {name: 'Ana'}), (bo:Person {name: 'Bo'}),
73
+ (staff:Group {name: 'Lab staff'}), (bsl3:Group {name: 'BSL-3'}),
74
+ (airlock:Door {name: 'BSL-3 airlock'})
75
+ CREATE (ana)-[:MEMBER_OF]->(bsl3)-[:PART_OF]->(staff),
76
+ (bo)-[:MEMBER_OF]->(staff),
77
+ (bsl3)-[:MAY_OPEN {from: localtime('07:00'), until: localtime('19:00')}]->(airlock)
78
+ """)
79
+
80
+ rows = db.query("""
81
+ MATCH (:Door {name: $door})<-[rule:MAY_OPEN]-(:Group)<-[:PART_OF*0..]-(:Group)<-[:MEMBER_OF]-(p:Person)
82
+ RETURN p.name, rule.from, rule.until
83
+ """, door="BSL-3 airlock")
84
+ print(rows) # [['Ana', datetime.time(7, 0), datetime.time(19, 0)]]
85
+ ```
86
+
87
+ Results come back as Python values: numbers, strings, lists, dicts, `datetime` types with their
88
+ time zones, and nodes, relationships and paths.
89
+
90
+ Full-text search, with stemming and BM25 ranking, in Neo4j's syntax:
91
+
92
+ ```python
93
+ db.query("CREATE (:Protocol {title: 'Airlock', body: 'Spray the doors before opening them'})")
94
+ db.query("""
95
+ CREATE FULLTEXT INDEX protocols FOR (p:Protocol) ON EACH [p.title, p.body]
96
+ OPTIONS {indexConfig: {`fulltext.analyzer`: 'english'}}
97
+ """)
98
+ print(db.query("""
99
+ CALL db.index.fulltext.queryNodes('protocols', 'door AND open') YIELD node, score
100
+ RETURN node.title, score
101
+ """)) # [['Airlock', 0.5753641449035617]]
102
+ ```
103
+
104
+ And a look at how a query runs: `explain` returns its plan, and `profile` runs it and counts the
105
+ rows each step made:
106
+
107
+ ```python
108
+ def show(plan, depth=0):
109
+ print(" " * depth + f"{plan['operator']} {plan['details']} rows: {plan['rows']}")
110
+ for child in plan["children"]:
111
+ show(child, depth + 1)
112
+
113
+ rows, plan = db.profile("""
114
+ MATCH (:Door {name: $door})<-[rule:MAY_OPEN]-(:Group)<-[:PART_OF*0..]-(:Group)<-[:MEMBER_OF]-(p:Person)
115
+ RETURN p.name, rule.from, rule.until
116
+ """, door="BSL-3 airlock")
117
+ show(plan)
118
+ ```
119
+
120
+ ```text
121
+ Return p.name, rule.from, rule.until rows: 1
122
+ Expand(All) (:Group)<-[:MEMBER_OF]-(p:Person) rows: 1
123
+ VarLengthExpand(All) (:Group)<-[:PART_OF*0..]-(:Group) rows: 1
124
+ Expand(All) (:Door {name: $door})<-[rule:MAY_OPEN]-(:Group) rows: 1
125
+ NodeIndexSeek (:Door {name: $door}) rows: 1
126
+ ```
127
+
128
+ The [tutorial](https://acasadom.github.io/zypherdb/tutorial/01-getting-started.html) goes from
129
+ here to a complete access-control system in twenty short steps.
130
+
131
+ ## What it can do
132
+
133
+ - **openCypher**: `MATCH` and `OPTIONAL MATCH`, variable-length and shortest paths, `WITH`,
134
+ `UNWIND`, `UNION`, subqueries, `EXISTS { }` and `COUNT { }`; `CREATE`, `MERGE`, `SET`,
135
+ `REMOVE`, `DELETE`, `FOREACH`; `LOAD CSV`; every aggregate; string, list, math, temporal and
136
+ graph functions.
137
+ - **Values**: integers, floats, strings, booleans, lists, maps, and the six temporal types with
138
+ time zones. Properties can also hold maps, so a node can carry a document.
139
+ - **Indexes**: property indexes for equality and ranges, on node labels and relationship types,
140
+ and on fields inside documents; full-text indexes in English and Spanish; uniqueness constraints.
141
+ - **Storage**: transactions, crash safety, three durability levels, one writer and any number of
142
+ readers across processes (readers never wait), and an integrity checker.
143
+ - **Queries**: plans of operators with index seeks, `EXPLAIN` and `PROFILE`, prepared statements
144
+ and a statement cache.
145
+
146
+ ZypherDB passes all 3202 scenarios of the [openCypher TCK](https://github.com/acasadom/zypherdb/blob/main/tests/tck/README.md)
147
+ that expect a result, and all 694 that expect an error. The
148
+ [Cypher reference](https://acasadom.github.io/zypherdb/guide/cypher.html) lists what it does not
149
+ support yet. Python is the first language binding; C, C++ and JavaScript come next.
150
+
151
+ ## Documentation
152
+
153
+ [acasadom.github.io/zypherdb](https://acasadom.github.io/zypherdb/) has the tutorial, the
154
+ [Cypher](https://acasadom.github.io/zypherdb/guide/cypher.html) and
155
+ [Python](https://acasadom.github.io/zypherdb/guide/python.html) references, and how it works
156
+ inside: the [architecture](https://acasadom.github.io/zypherdb/guide/architecture.html), the
157
+ storage layout, the query planner, [performance](https://acasadom.github.io/zypherdb/guide/performance.html)
158
+ and [testing](https://acasadom.github.io/zypherdb/guide/testing.html) (fuzzers, crash and fault
159
+ injection, the TCK).
160
+
161
+ ## Building from source
162
+
163
+ You need [Zig 0.17](https://ziglang.org/download/): `zig build test` runs the tests and
164
+ `pip install .` builds the Python package. The
165
+ [contributing guide](https://acasadom.github.io/zypherdb/guide/contributing.html) has the rest.
166
+
167
+ ## License
168
+
169
+ Apache License 2.0. ZypherDB includes LMDB, libmdbx, the IANA time-zone database, and data and
170
+ algorithms from Unicode and Snowball, under their own licenses: see
171
+ [THIRD_PARTY_NOTICES.md](https://github.com/acasadom/zypherdb/blob/main/THIRD_PARTY_NOTICES.md).
@@ -0,0 +1,134 @@
1
+ # ZypherDB
2
+
3
+ *An embedded graph database that speaks openCypher.*
4
+
5
+ [![CI](https://github.com/acasadom/zypherdb/actions/workflows/ci.yml/badge.svg)](https://github.com/acasadom/zypherdb/actions/workflows/ci.yml)
6
+ [![License: Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/acasadom/zypherdb/blob/main/LICENSE)
7
+ ![Python](https://img.shields.io/badge/python-3.10%2B-blue)
8
+ [![Docs](https://img.shields.io/badge/docs-acasadom.github.io%2Fzypherdb-blue)](https://acasadom.github.io/zypherdb/)
9
+
10
+ ZypherDB is to graphs what SQLite is to tables: a database that lives inside your process and
11
+ keeps its data in a directory, with no server to run. You store nodes and relationships and
12
+ query them in **openCypher**, the language of Neo4j. Several processes can share a database, and
13
+ a crash never leaves it half-written. The engine is written in Zig, on LMDB.
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ pip install zypherdb
19
+ ```
20
+
21
+ Python 3.10 or later, on Linux (x86_64, aarch64), macOS (Apple silicon, Intel) and Windows
22
+ (x86_64). No dependencies (on Windows, only `tzdata`).
23
+
24
+ ## A first look
25
+
26
+ Who may open a door, through groups nested to any depth, and at what times:
27
+
28
+ ```python
29
+ from zypherdb import Database
30
+
31
+ db = Database("lab.db") # a directory, created if missing
32
+
33
+ db.query("CREATE INDEX FOR (d:Door) ON (d.name)") # doors are looked up by name
34
+ db.query("""
35
+ CREATE (ana:Person {name: 'Ana'}), (bo:Person {name: 'Bo'}),
36
+ (staff:Group {name: 'Lab staff'}), (bsl3:Group {name: 'BSL-3'}),
37
+ (airlock:Door {name: 'BSL-3 airlock'})
38
+ CREATE (ana)-[:MEMBER_OF]->(bsl3)-[:PART_OF]->(staff),
39
+ (bo)-[:MEMBER_OF]->(staff),
40
+ (bsl3)-[:MAY_OPEN {from: localtime('07:00'), until: localtime('19:00')}]->(airlock)
41
+ """)
42
+
43
+ rows = db.query("""
44
+ MATCH (:Door {name: $door})<-[rule:MAY_OPEN]-(:Group)<-[:PART_OF*0..]-(:Group)<-[:MEMBER_OF]-(p:Person)
45
+ RETURN p.name, rule.from, rule.until
46
+ """, door="BSL-3 airlock")
47
+ print(rows) # [['Ana', datetime.time(7, 0), datetime.time(19, 0)]]
48
+ ```
49
+
50
+ Results come back as Python values: numbers, strings, lists, dicts, `datetime` types with their
51
+ time zones, and nodes, relationships and paths.
52
+
53
+ Full-text search, with stemming and BM25 ranking, in Neo4j's syntax:
54
+
55
+ ```python
56
+ db.query("CREATE (:Protocol {title: 'Airlock', body: 'Spray the doors before opening them'})")
57
+ db.query("""
58
+ CREATE FULLTEXT INDEX protocols FOR (p:Protocol) ON EACH [p.title, p.body]
59
+ OPTIONS {indexConfig: {`fulltext.analyzer`: 'english'}}
60
+ """)
61
+ print(db.query("""
62
+ CALL db.index.fulltext.queryNodes('protocols', 'door AND open') YIELD node, score
63
+ RETURN node.title, score
64
+ """)) # [['Airlock', 0.5753641449035617]]
65
+ ```
66
+
67
+ And a look at how a query runs: `explain` returns its plan, and `profile` runs it and counts the
68
+ rows each step made:
69
+
70
+ ```python
71
+ def show(plan, depth=0):
72
+ print(" " * depth + f"{plan['operator']} {plan['details']} rows: {plan['rows']}")
73
+ for child in plan["children"]:
74
+ show(child, depth + 1)
75
+
76
+ rows, plan = db.profile("""
77
+ MATCH (:Door {name: $door})<-[rule:MAY_OPEN]-(:Group)<-[:PART_OF*0..]-(:Group)<-[:MEMBER_OF]-(p:Person)
78
+ RETURN p.name, rule.from, rule.until
79
+ """, door="BSL-3 airlock")
80
+ show(plan)
81
+ ```
82
+
83
+ ```text
84
+ Return p.name, rule.from, rule.until rows: 1
85
+ Expand(All) (:Group)<-[:MEMBER_OF]-(p:Person) rows: 1
86
+ VarLengthExpand(All) (:Group)<-[:PART_OF*0..]-(:Group) rows: 1
87
+ Expand(All) (:Door {name: $door})<-[rule:MAY_OPEN]-(:Group) rows: 1
88
+ NodeIndexSeek (:Door {name: $door}) rows: 1
89
+ ```
90
+
91
+ The [tutorial](https://acasadom.github.io/zypherdb/tutorial/01-getting-started.html) goes from
92
+ here to a complete access-control system in twenty short steps.
93
+
94
+ ## What it can do
95
+
96
+ - **openCypher**: `MATCH` and `OPTIONAL MATCH`, variable-length and shortest paths, `WITH`,
97
+ `UNWIND`, `UNION`, subqueries, `EXISTS { }` and `COUNT { }`; `CREATE`, `MERGE`, `SET`,
98
+ `REMOVE`, `DELETE`, `FOREACH`; `LOAD CSV`; every aggregate; string, list, math, temporal and
99
+ graph functions.
100
+ - **Values**: integers, floats, strings, booleans, lists, maps, and the six temporal types with
101
+ time zones. Properties can also hold maps, so a node can carry a document.
102
+ - **Indexes**: property indexes for equality and ranges, on node labels and relationship types,
103
+ and on fields inside documents; full-text indexes in English and Spanish; uniqueness constraints.
104
+ - **Storage**: transactions, crash safety, three durability levels, one writer and any number of
105
+ readers across processes (readers never wait), and an integrity checker.
106
+ - **Queries**: plans of operators with index seeks, `EXPLAIN` and `PROFILE`, prepared statements
107
+ and a statement cache.
108
+
109
+ ZypherDB passes all 3202 scenarios of the [openCypher TCK](https://github.com/acasadom/zypherdb/blob/main/tests/tck/README.md)
110
+ that expect a result, and all 694 that expect an error. The
111
+ [Cypher reference](https://acasadom.github.io/zypherdb/guide/cypher.html) lists what it does not
112
+ support yet. Python is the first language binding; C, C++ and JavaScript come next.
113
+
114
+ ## Documentation
115
+
116
+ [acasadom.github.io/zypherdb](https://acasadom.github.io/zypherdb/) has the tutorial, the
117
+ [Cypher](https://acasadom.github.io/zypherdb/guide/cypher.html) and
118
+ [Python](https://acasadom.github.io/zypherdb/guide/python.html) references, and how it works
119
+ inside: the [architecture](https://acasadom.github.io/zypherdb/guide/architecture.html), the
120
+ storage layout, the query planner, [performance](https://acasadom.github.io/zypherdb/guide/performance.html)
121
+ and [testing](https://acasadom.github.io/zypherdb/guide/testing.html) (fuzzers, crash and fault
122
+ injection, the TCK).
123
+
124
+ ## Building from source
125
+
126
+ You need [Zig 0.17](https://ziglang.org/download/): `zig build test` runs the tests and
127
+ `pip install .` builds the Python package. The
128
+ [contributing guide](https://acasadom.github.io/zypherdb/guide/contributing.html) has the rest.
129
+
130
+ ## License
131
+
132
+ Apache License 2.0. ZypherDB includes LMDB, libmdbx, the IANA time-zone database, and data and
133
+ algorithms from Unicode and Snowball, under their own licenses: see
134
+ [THIRD_PARTY_NOTICES.md](https://github.com/acasadom/zypherdb/blob/main/THIRD_PARTY_NOTICES.md).
@@ -0,0 +1,109 @@
1
+ # Third-party notices
2
+
3
+ ZypherDB includes, or is derived from, the following works. Their licenses are reproduced below.
4
+
5
+ | Work | Where | License |
6
+ | --- | --- | --- |
7
+ | LMDB (Symas Corporation, OpenLDAP Foundation) | `vendor/lmdb/` | OpenLDAP Public License 2.8 (`vendor/lmdb/LICENSE`) |
8
+ | libmdbx 0.14.4 (Leonid Yuriev), with the local change listed in `vendor/libmdbx/PATCHES.md` | `vendor/libmdbx/` | Apache License 2.0 (`vendor/libmdbx/LICENSE`; its NOTICE below) |
9
+ | IANA time zone database 2026.5, as compiled to TZif by the tzdata Python package (Paul Ganssle, Stan Ulbrych) | `vendor/tzdata/` | The data is in the public domain; the package is under the Apache License 2.0 (`vendor/tzdata/LICENSE`, `vendor/tzdata/LICENSE_APACHE`) |
10
+ | Unicode Character Database 16.0 (tables generated from it) | `src/text/unicode_tables.zig` | Unicode License v3 (below) |
11
+ | Snowball stemming algorithms (English "Porter2", Spanish), translated to Zig; the Snowball Spanish stop-word list | `src/text/stem_english.zig`, `src/text/stem_spanish.zig`, `src/text/stop_words.zig` | BSD 3-Clause (below) |
12
+ | Snowball test vocabularies (a sample) | `tests/text/snowball/` (tests only) | BSD 3-Clause (below) |
13
+ | openCypher Technology Compatibility Kit | `tests/tck/features/` (tests only) | Apache License 2.0 (`tests/tck/LICENSE`) |
14
+
15
+ The English stop words are Lucene's English stop set, a list of 33 common English words.
16
+
17
+ ## libmdbx (Apache License 2.0)
18
+
19
+ ZypherDB's builds with the libmdbx engine (`-Dstorage-engine=mdbx`) contain libmdbx, compiled from
20
+ `vendor/libmdbx/mdbx.c` as modified by ZypherDB (`vendor/libmdbx/PATCHES.md`). The
21
+ attribution notice of its NOTICE file:
22
+
23
+ ```text
24
+ libmdbx (aka MDBX) is an extremely fast, compact, powerful, embeddedable,
25
+ transactional key-value storage engine with open-source code.
26
+
27
+ Copyright 2015-2026 Леонид Юрьев aka Leonid Yuriev <leo@yuriev.ru>
28
+ SPDX-License-Identifier: Apache-2.0
29
+ For notes about the license change, credits and acknowledgments,
30
+ please refer to the COPYRIGHT file within libmdbx source.
31
+ ```
32
+
33
+ ## Snowball (BSD 3-Clause)
34
+
35
+ ```text
36
+ Copyright (c) 2001, Dr Martin Porter
37
+ Copyright (c) 2004,2005, Richard Boulton
38
+ Copyright (c) 2013, Yoshiki Shibukawa
39
+ Copyright (c) 2006-2025, Olly Betts
40
+ All rights reserved.
41
+
42
+ Redistribution and use in source and binary forms, with or without
43
+ modification, are permitted provided that the following conditions
44
+ are met:
45
+
46
+ 1. Redistributions of source code must retain the above copyright notice,
47
+ this list of conditions and the following disclaimer.
48
+ 2. Redistributions in binary form must reproduce the above copyright notice,
49
+ this list of conditions and the following disclaimer in the documentation
50
+ and/or other materials provided with the distribution.
51
+ 3. Neither the name of the Snowball project nor the names of its contributors
52
+ may be used to endorse or promote products derived from this software
53
+ without specific prior written permission.
54
+
55
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
56
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
57
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
58
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
59
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
60
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
61
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
62
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
63
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
64
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
65
+ ```
66
+
67
+ ## Unicode License v3
68
+
69
+ ```text
70
+ UNICODE LICENSE V3
71
+
72
+ COPYRIGHT AND PERMISSION NOTICE
73
+
74
+ Copyright © 1991-2026 Unicode, Inc.
75
+
76
+ NOTICE TO USER: Carefully read the following legal agreement. BY
77
+ DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR
78
+ SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
79
+ TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT
80
+ DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
81
+
82
+ Permission is hereby granted, free of charge, to any person obtaining a
83
+ copy of data files and any associated documentation (the "Data Files") or
84
+ software and any associated documentation (the "Software") to deal in the
85
+ Data Files or Software without restriction, including without limitation
86
+ the rights to use, copy, modify, merge, publish, distribute, and/or sell
87
+ copies of the Data Files or Software, and to permit persons to whom the
88
+ Data Files or Software are furnished to do so, provided that either (a)
89
+ this copyright and permission notice appear with all copies of the Data
90
+ Files or Software, or (b) this copyright and permission notice appear in
91
+ associated Documentation.
92
+
93
+ THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
94
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
95
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
96
+ THIRD PARTY RIGHTS.
97
+
98
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE
99
+ BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
100
+ OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
101
+ WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
102
+ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA
103
+ FILES OR SOFTWARE.
104
+
105
+ Except as contained in this notice, the name of a copyright holder shall
106
+ not be used in advertising or otherwise to promote the sale, use or other
107
+ dealings in these Data Files or Software without prior written
108
+ authorization of the copyright holder.
109
+ ```