pygtvdb 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.
@@ -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 acting entity and all other entities
16
+ that control, are controlled by, or are under common control with that
17
+ entity. For the purposes of this definition, "control" means (i) the
18
+ power, direct or indirect, to cause the direction or management of
19
+ such entity, whether by contract or otherwise, or (ii) ownership of
20
+ fifty percent (50%) or more of the outstanding shares, or (iii) beneficial
21
+ 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 2026 gtvdb Authors
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,6 @@
1
+ # setuptools' default sdist heuristics pick up `tests/test*.py` but skip
2
+ # `tests/_fake_server.py`, which the tests import — so the sdist's suite would
3
+ # error on collection. Name the files explicitly instead of relying on globs.
4
+ include README.md
5
+ recursive-include tests *.py
6
+ prune tests/__pycache__
pygtvdb-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,147 @@
1
+ Metadata-Version: 2.4
2
+ Name: pygtvdb
3
+ Version: 0.1.0
4
+ Summary: DB-API 2.0 driver for the gtv temporal-graph engine (import gtvdb)
5
+ Author: gtvdb
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/jacalwu/gtvdb_core
8
+ Project-URL: Documentation, https://github.com/jacalwu/gtvdb_core/blob/main/docs/user-guide.md
9
+ Project-URL: Changelog, https://github.com/jacalwu/gtvdb_core/blob/main/docs/api-compat.md
10
+ Project-URL: Source, https://github.com/jacalwu/gtvdb_core/tree/main/python
11
+ Project-URL: Issues, https://github.com/jacalwu/gtvdb_core/issues
12
+ Keywords: database,dbapi,driver,temporal,bitemporal,graph,arrow,grpc,gtv
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Typing :: Typed
24
+ Classifier: Topic :: Database
25
+ Classifier: Topic :: Database :: Front-Ends
26
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
27
+ Requires-Python: >=3.9
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE.md
30
+ Requires-Dist: grpcio>=1.60
31
+ Requires-Dist: pyarrow>=14
32
+ Provides-Extra: pandas
33
+ Requires-Dist: pandas>=2.0; extra == "pandas"
34
+ Provides-Extra: polars
35
+ Requires-Dist: polars>=0.20; extra == "polars"
36
+ Dynamic: license-file
37
+
38
+ # gtvdb (Python)
39
+
40
+ DB-API 2.0 driver for the gtv temporal-graph engine. Pure Python over gRPC —
41
+ nothing to compile, no platform wheel, no `protoc` on the user's machine.
42
+
43
+ ```bash
44
+ pip install pygtvdb # or: pip install pygtvdb[pandas]
45
+ ```
46
+
47
+ > The PyPI distribution is named **`pygtvdb`** (the shorter `gtvdb` name was
48
+ > unavailable at publish time), but you still **`import gtvdb`** in Python —
49
+ > distribution name and import name are deliberately decoupled, so the code
50
+ > below is unchanged from earlier previews.
51
+
52
+ Requires Python 3.9+ and a reachable engine. The driver is a client only: it
53
+ does not embed the engine, and it cannot create one. The quickest engine is the
54
+ published container image (no Rust toolchain, no git clone):
55
+
56
+ ```bash
57
+ docker run --rm -p 50051:50051 -e GTV_ADDR=0.0.0.0:50051 \
58
+ ghcr.io/jacalwu/gtvdb-core:0.1.0 gtv-demo-server
59
+ # in another shell: pip install pygtvdb && python your_client.py
60
+ ```
61
+
62
+ The image also ships `gtv`, the zero-extension SQL REPL
63
+ (`docker run --rm -it ghcr.io/jacalwu/gtvdb-core:0.1.0`). Linux binaries are on
64
+ the GitHub release tagged `v*`. The `gtv-demo-server` serves one immutable
65
+ snapshot for protocol development; the production store-backed engine
66
+ (`gtv-server`) lives in the companion `gtvdb_ext` repository. From a source
67
+ checkout, `cargo run -p gtv-engine --example serve_demo` works too.
68
+
69
+ ```python
70
+ import gtvdb
71
+
72
+ con = gtvdb.connect("gtv://127.0.0.1:50051")
73
+ cur = con.cursor()
74
+ cur.execute("SELECT * FROM numbers WHERE n <= ?", (3,))
75
+ print(cur.fetchall()) # [(1, 1.0), (2, 4.0), (3, 9.0)]
76
+ print(cur.description[0][0]) # 'n'
77
+ con.close()
78
+ ```
79
+
80
+ Works with pandas out of the box:
81
+
82
+ ```python
83
+ import pandas as pd
84
+ pd.read_sql("SELECT * FROM prices ORDER BY t", con)
85
+ ```
86
+
87
+ ## Pinning business time
88
+
89
+ `as_of` is the engine's "answer as of T", and it belongs to the connection, not
90
+ to each query — the equivalent of opening a kdb+ session at a timestamp:
91
+
92
+ ```python
93
+ con = gtvdb.connect("gtv://host:50051", as_of=1_700_000_000_000_000_000)
94
+ con.cursor().execute("SELECT count(*) FROM positions").fetchall()
95
+
96
+ at_open = con.pin(as_of=1_700_000_000_000_000_000) # same channel, new pin
97
+ ```
98
+
99
+ ## Evidence, for workloads that need it
100
+
101
+ DB-API cannot express "this empty result proves nothing", so the cursor keeps
102
+ the engine's answer alongside the rows:
103
+
104
+ ```python
105
+ cur.execute("SELECT * FROM edges WHERE src = ?", (99,))
106
+ cur.fetchall() # []
107
+ cur.tri_state # 'no_match' -> absence is proven
108
+ cur.receipt # full QueryReceipt: snapshot, as_of, freshness
109
+ ```
110
+
111
+ `tri_state == "incomplete"` (budget or deadline hit) means the empty result
112
+ proves nothing. `cur.is_conclusive` is `False` for an old server that cannot
113
+ compute a tri-state at all.
114
+
115
+ ## What it is not
116
+
117
+ * **Read-only.** `commit()` / `rollback()` are no-ops; DML is refused by the
118
+ engine, not faked by the driver. Writes belong to an RDBMS or Redis that
119
+ refreshes into the store.
120
+ * **Not a wire format of its own.** It speaks `gtvquery.QueryService` v1
121
+ (`crates/gtv-proto/proto/gtvquery.proto`), the same contract the Rust client
122
+ uses. `?` parameters are rendered client-side into typed literals, because
123
+ protocol v1 has no bind slots.
124
+
125
+ ## Development
126
+
127
+ ```bash
128
+ pip install -e ./python # from the gtvdb_core repo root
129
+ python python/gen_stubs.py # regenerate gtvdb/_stubs from the .proto
130
+ python python/gen_stubs.py --check # CI: fail if stubs drift
131
+ python -m pytest python/tests # unit tests, no server needed
132
+ ```
133
+
134
+ ## Releasing
135
+
136
+ The version lives in exactly one place, `gtvdb/_version.py`; `pyproject.toml`
137
+ reads it back rather than repeating it. Before an upload:
138
+
139
+ ```bash
140
+ python python/check_release.py # licence copy, stub freshness, tests,
141
+ # metadata, artefact contents, name on PyPI
142
+ ```
143
+
144
+ Pushing a `py-v*` tag publishes through GitHub Actions with PyPI trusted
145
+ publishing, so no token is stored anywhere. The full procedure — including the
146
+ first-release bootstrap, TestPyPI rehearsal, and why a version number can never
147
+ be reused — is in [PUBLISHING.md](https://github.com/jacalwu/gtvdb_core/blob/main/python/PUBLISHING.md).
@@ -0,0 +1,110 @@
1
+ # gtvdb (Python)
2
+
3
+ DB-API 2.0 driver for the gtv temporal-graph engine. Pure Python over gRPC —
4
+ nothing to compile, no platform wheel, no `protoc` on the user's machine.
5
+
6
+ ```bash
7
+ pip install pygtvdb # or: pip install pygtvdb[pandas]
8
+ ```
9
+
10
+ > The PyPI distribution is named **`pygtvdb`** (the shorter `gtvdb` name was
11
+ > unavailable at publish time), but you still **`import gtvdb`** in Python —
12
+ > distribution name and import name are deliberately decoupled, so the code
13
+ > below is unchanged from earlier previews.
14
+
15
+ Requires Python 3.9+ and a reachable engine. The driver is a client only: it
16
+ does not embed the engine, and it cannot create one. The quickest engine is the
17
+ published container image (no Rust toolchain, no git clone):
18
+
19
+ ```bash
20
+ docker run --rm -p 50051:50051 -e GTV_ADDR=0.0.0.0:50051 \
21
+ ghcr.io/jacalwu/gtvdb-core:0.1.0 gtv-demo-server
22
+ # in another shell: pip install pygtvdb && python your_client.py
23
+ ```
24
+
25
+ The image also ships `gtv`, the zero-extension SQL REPL
26
+ (`docker run --rm -it ghcr.io/jacalwu/gtvdb-core:0.1.0`). Linux binaries are on
27
+ the GitHub release tagged `v*`. The `gtv-demo-server` serves one immutable
28
+ snapshot for protocol development; the production store-backed engine
29
+ (`gtv-server`) lives in the companion `gtvdb_ext` repository. From a source
30
+ checkout, `cargo run -p gtv-engine --example serve_demo` works too.
31
+
32
+ ```python
33
+ import gtvdb
34
+
35
+ con = gtvdb.connect("gtv://127.0.0.1:50051")
36
+ cur = con.cursor()
37
+ cur.execute("SELECT * FROM numbers WHERE n <= ?", (3,))
38
+ print(cur.fetchall()) # [(1, 1.0), (2, 4.0), (3, 9.0)]
39
+ print(cur.description[0][0]) # 'n'
40
+ con.close()
41
+ ```
42
+
43
+ Works with pandas out of the box:
44
+
45
+ ```python
46
+ import pandas as pd
47
+ pd.read_sql("SELECT * FROM prices ORDER BY t", con)
48
+ ```
49
+
50
+ ## Pinning business time
51
+
52
+ `as_of` is the engine's "answer as of T", and it belongs to the connection, not
53
+ to each query — the equivalent of opening a kdb+ session at a timestamp:
54
+
55
+ ```python
56
+ con = gtvdb.connect("gtv://host:50051", as_of=1_700_000_000_000_000_000)
57
+ con.cursor().execute("SELECT count(*) FROM positions").fetchall()
58
+
59
+ at_open = con.pin(as_of=1_700_000_000_000_000_000) # same channel, new pin
60
+ ```
61
+
62
+ ## Evidence, for workloads that need it
63
+
64
+ DB-API cannot express "this empty result proves nothing", so the cursor keeps
65
+ the engine's answer alongside the rows:
66
+
67
+ ```python
68
+ cur.execute("SELECT * FROM edges WHERE src = ?", (99,))
69
+ cur.fetchall() # []
70
+ cur.tri_state # 'no_match' -> absence is proven
71
+ cur.receipt # full QueryReceipt: snapshot, as_of, freshness
72
+ ```
73
+
74
+ `tri_state == "incomplete"` (budget or deadline hit) means the empty result
75
+ proves nothing. `cur.is_conclusive` is `False` for an old server that cannot
76
+ compute a tri-state at all.
77
+
78
+ ## What it is not
79
+
80
+ * **Read-only.** `commit()` / `rollback()` are no-ops; DML is refused by the
81
+ engine, not faked by the driver. Writes belong to an RDBMS or Redis that
82
+ refreshes into the store.
83
+ * **Not a wire format of its own.** It speaks `gtvquery.QueryService` v1
84
+ (`crates/gtv-proto/proto/gtvquery.proto`), the same contract the Rust client
85
+ uses. `?` parameters are rendered client-side into typed literals, because
86
+ protocol v1 has no bind slots.
87
+
88
+ ## Development
89
+
90
+ ```bash
91
+ pip install -e ./python # from the gtvdb_core repo root
92
+ python python/gen_stubs.py # regenerate gtvdb/_stubs from the .proto
93
+ python python/gen_stubs.py --check # CI: fail if stubs drift
94
+ python -m pytest python/tests # unit tests, no server needed
95
+ ```
96
+
97
+ ## Releasing
98
+
99
+ The version lives in exactly one place, `gtvdb/_version.py`; `pyproject.toml`
100
+ reads it back rather than repeating it. Before an upload:
101
+
102
+ ```bash
103
+ python python/check_release.py # licence copy, stub freshness, tests,
104
+ # metadata, artefact contents, name on PyPI
105
+ ```
106
+
107
+ Pushing a `py-v*` tag publishes through GitHub Actions with PyPI trusted
108
+ publishing, so no token is stored anywhere. The full procedure — including the
109
+ first-release bootstrap, TestPyPI rehearsal, and why a version number can never
110
+ be reused — is in [PUBLISHING.md](https://github.com/jacalwu/gtvdb_core/blob/main/python/PUBLISHING.md).
@@ -0,0 +1,143 @@
1
+ """gtvdb — a DB-API 2.0 driver for the gtv temporal-graph engine.
2
+
3
+ import gtvdb
4
+
5
+ with gtvdb.connect("gtv://127.0.0.1:50051") as con:
6
+ with con.cursor() as cur:
7
+ cur.execute("SELECT * FROM numbers WHERE n <= ?", (3,))
8
+ print(cur.fetchall()) # [(1, 1.0), (2, 4.0), (3, 9.0)]
9
+
10
+ import pandas as pd
11
+ print(pd.read_sql("SELECT * FROM prices", con))
12
+
13
+ Install with `pip install pygtvdb`; there is nothing to compile — the driver is
14
+ pure Python over gRPC, and Arrow comes from `pyarrow`.
15
+
16
+ # The three layers, in case you need to drop below DB-API
17
+
18
+ | layer | object | what it adds |
19
+ |---|---|---|
20
+ | DB-API 2.0 | `Connection` / `Cursor` | `execute` / `fetchall` / `description`, pandas, SQLAlchemy |
21
+ | session | `Session` / `Result` | `as_of` pinning, `QueryReceipt`, `tri_state` |
22
+ | wire | `gtvdb._stubs` | `gtvquery.QueryService`, protocol v1 |
23
+
24
+ DB-API has no vocabulary for "this empty result proves nothing", so the cursor
25
+ keeps the engine's own answer: `cur.tri_state == "no_match"` means absence was
26
+ proven, `"incomplete"` means it was not. Detection workloads must read it;
27
+ reporting workloads can ignore it.
28
+ """
29
+
30
+ from __future__ import annotations
31
+
32
+ from typing import Any, Optional
33
+
34
+ from . import _version
35
+ from .client import DEFAULT_ADDR, GtvError, Result, Session
36
+ from .connection import Connection
37
+ from .cursor import (
38
+ BINARY,
39
+ BOOLEAN,
40
+ DATETIME,
41
+ INTEGER,
42
+ NUMBER,
43
+ ROWID,
44
+ STRING,
45
+ Cursor,
46
+ )
47
+ from .errors import (
48
+ DataError,
49
+ DatabaseError,
50
+ Error,
51
+ IntegrityError,
52
+ InterfaceError,
53
+ InternalError,
54
+ NotSupportedError,
55
+ OperationalError,
56
+ ProgrammingError,
57
+ Warning,
58
+ )
59
+
60
+ #: Single-sourced from `_version.py` so `pyproject.toml` and the runtime can
61
+ #: never disagree about what was published.
62
+ __version__ = _version.__version__
63
+
64
+ # --- PEP 249 module attributes ---------------------------------------------
65
+ apilevel = "2.0"
66
+ #: Threads may share the module and connections (the gRPC channel is thread
67
+ #: safe, and each cursor owns its result). Cursors themselves are not shared.
68
+ threadsafety = 2
69
+ #: `?` placeholders, rendered client-side (see `_params.py` for the exact rules).
70
+ paramstyle = "qmark"
71
+
72
+
73
+ def connect(
74
+ dsn: Optional[str] = None,
75
+ *,
76
+ host: str = "127.0.0.1",
77
+ port: int = 50051,
78
+ as_of: Optional[int] = None,
79
+ snapshot_id: Optional[int] = None,
80
+ token: Optional[str] = None,
81
+ ca_cert: Optional[str] = None,
82
+ timeout_ms: Optional[int] = None,
83
+ **kwargs: Any,
84
+ ) -> Connection:
85
+ """Open a connection. `dsn` is `gtv://host:port`, or pass `host`/`port`.
86
+
87
+ gtvdb.connect() # 127.0.0.1:50051
88
+ gtvdb.connect("gtv://engine.internal:50061")
89
+ gtvdb.connect("gtv://host:50051?as_of=1700000000000000000")
90
+ gtvdb.connect(host="10.0.0.5", port=50051, token="...")
91
+
92
+ `as_of` pins business time for every query on this connection — the
93
+ equivalent of opening a kdb+ session at T. `token` is sent as a bearer
94
+ token; `ca_cert` is a PEM path and switches the channel to TLS.
95
+ """
96
+ if kwargs:
97
+ unknown = ", ".join(sorted(kwargs))
98
+ raise TypeError(f"connect() got unexpected keyword argument(s): {unknown}")
99
+ return Connection.open(
100
+ dsn,
101
+ host=host,
102
+ port=port,
103
+ as_of=as_of,
104
+ snapshot_id=snapshot_id,
105
+ token=token,
106
+ ca_cert=ca_cert,
107
+ timeout_ms=timeout_ms,
108
+ )
109
+
110
+
111
+ __all__ = [
112
+ # PEP 249
113
+ "apilevel",
114
+ "threadsafety",
115
+ "paramstyle",
116
+ "connect",
117
+ "Connection",
118
+ "Cursor",
119
+ "Warning",
120
+ "Error",
121
+ "InterfaceError",
122
+ "DatabaseError",
123
+ "DataError",
124
+ "OperationalError",
125
+ "IntegrityError",
126
+ "InternalError",
127
+ "ProgrammingError",
128
+ "NotSupportedError",
129
+ # type objects for `description`
130
+ "STRING",
131
+ "BINARY",
132
+ "NUMBER",
133
+ "INTEGER",
134
+ "DATETIME",
135
+ "ROWID",
136
+ "BOOLEAN",
137
+ # lower layers
138
+ "Session",
139
+ "Result",
140
+ "GtvError",
141
+ "DEFAULT_ADDR",
142
+ "__version__",
143
+ ]