tigrbl_engine_clickhouse 0.1.1.dev2__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,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,71 @@
1
+ Metadata-Version: 2.4
2
+ Name: tigrbl_engine_clickhouse
3
+ Version: 0.1.1.dev2
4
+ Summary: Tigrbl engine plugin providing ClickHouse database support.
5
+ Author-email: Jacob Stewart <jacob@swarmauri.com>
6
+ License: Apache-2.0
7
+ Keywords: tigrbl,engine,plugin,clickhouse,database,analytics
8
+ Classifier: Development Status :: 1 - Planning
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Programming Language :: Python
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Environment :: Plugins
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: Topic :: Database
19
+ Classifier: Topic :: Software Development :: Libraries
20
+ Requires-Python: <3.13,>=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: tigrbl>=0.3.0.dev4
24
+ Requires-Dist: clickhouse-connect>=0.6.0
25
+ Dynamic: license-file
26
+
27
+ # tigrbl_engine_clickhouse
28
+
29
+ A ClickHouse engine plugin for **tigrbl**. This package registers a new engine
30
+ kind `"clickhouse"` that tigrbl auto‑discovers via the `tigrbl.engine` entry‑point group.
31
+
32
+ > Both classes in this package are **subclasses of tigrbl's first‑class objects**.
33
+
34
+ ## Installation
35
+
36
+ ```bash
37
+ pip install tigrbl_engine_clickhouse
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ ```python
43
+ from tigrbl.engine.engine_spec import EngineSpec
44
+
45
+ spec = EngineSpec(kind="clickhouse", mapping={
46
+ "host": "localhost",
47
+ "port": 8123,
48
+ "username": "default",
49
+ "password": "",
50
+ "database": "default",
51
+ "secure": False,
52
+ })
53
+ eng, make_session = spec.build() # resolved via entry-points
54
+ s = make_session() # returns a ClickHouseSession (TigrblSessionBase subclass)
55
+
56
+ # Example query
57
+ rows = await s._execute_impl("SELECT 1 AS x")
58
+ print(rows)
59
+ await s.close()
60
+ ```
61
+
62
+ ### How it’s wired
63
+
64
+ - `pyproject.toml` declares the entry‑point:
65
+ ```toml
66
+ [project.entry-points."tigrbl.engine"]
67
+ clickhouse = "tigrbl_engine_clickhouse:register"
68
+ ```
69
+ - `register()` (in `__init__.py`) calls `tigrbl.engine.registry.register_engine("clickhouse", clickhouse_engine)`.
70
+ - `ClickHouseEngine` subclasses `tigrbl.engine._engine.Engine`.
71
+ - `ClickHouseSession` subclasses `tigrbl.session.base.TigrblSessionBase` and uses `clickhouse_connect`.
@@ -0,0 +1,45 @@
1
+ # tigrbl_engine_clickhouse
2
+
3
+ A ClickHouse engine plugin for **tigrbl**. This package registers a new engine
4
+ kind `"clickhouse"` that tigrbl auto‑discovers via the `tigrbl.engine` entry‑point group.
5
+
6
+ > Both classes in this package are **subclasses of tigrbl's first‑class objects**.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ pip install tigrbl_engine_clickhouse
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ```python
17
+ from tigrbl.engine.engine_spec import EngineSpec
18
+
19
+ spec = EngineSpec(kind="clickhouse", mapping={
20
+ "host": "localhost",
21
+ "port": 8123,
22
+ "username": "default",
23
+ "password": "",
24
+ "database": "default",
25
+ "secure": False,
26
+ })
27
+ eng, make_session = spec.build() # resolved via entry-points
28
+ s = make_session() # returns a ClickHouseSession (TigrblSessionBase subclass)
29
+
30
+ # Example query
31
+ rows = await s._execute_impl("SELECT 1 AS x")
32
+ print(rows)
33
+ await s.close()
34
+ ```
35
+
36
+ ### How it’s wired
37
+
38
+ - `pyproject.toml` declares the entry‑point:
39
+ ```toml
40
+ [project.entry-points."tigrbl.engine"]
41
+ clickhouse = "tigrbl_engine_clickhouse:register"
42
+ ```
43
+ - `register()` (in `__init__.py`) calls `tigrbl.engine.registry.register_engine("clickhouse", clickhouse_engine)`.
44
+ - `ClickHouseEngine` subclasses `tigrbl.engine._engine.Engine`.
45
+ - `ClickHouseSession` subclasses `tigrbl.session.base.TigrblSessionBase` and uses `clickhouse_connect`.
@@ -0,0 +1,62 @@
1
+ [project]
2
+ name = "tigrbl_engine_clickhouse"
3
+ version = "0.1.1.dev2"
4
+ description = "Tigrbl engine plugin providing ClickHouse database support."
5
+ readme = "README.md"
6
+ license = { text = "Apache-2.0" }
7
+ requires-python = ">=3.10,<3.13"
8
+ authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
9
+ classifiers = [
10
+ "Development Status :: 1 - Planning",
11
+ "License :: OSI Approved :: Apache Software License",
12
+ "Programming Language :: Python",
13
+ "Programming Language :: Python :: 3",
14
+ "Programming Language :: Python :: 3 :: Only",
15
+ "Programming Language :: Python :: 3.10",
16
+ "Programming Language :: Python :: 3.11",
17
+ "Programming Language :: Python :: 3.12",
18
+ "Environment :: Plugins",
19
+ "Intended Audience :: Developers",
20
+ "Topic :: Database",
21
+ "Topic :: Software Development :: Libraries",
22
+ ]
23
+ keywords = [
24
+ "tigrbl",
25
+ "engine",
26
+ "plugin",
27
+ "clickhouse",
28
+ "database",
29
+ "analytics",
30
+ ]
31
+ dependencies = [
32
+ "tigrbl>=0.3.0.dev4",
33
+ "clickhouse-connect>=0.6.0",
34
+ ]
35
+
36
+ [project.entry-points."tigrbl.engine"]
37
+ clickhouse = "tigrbl_engine_clickhouse:register"
38
+
39
+ [build-system]
40
+ requires = ["setuptools>=68", "wheel"]
41
+ build-backend = "setuptools.build_meta"
42
+
43
+ [tool.setuptools]
44
+ package-dir = {"" = "src"}
45
+
46
+ [tool.setuptools.packages.find]
47
+ where = ["src"]
48
+ include = ["tigrbl_engine_clickhouse*"]
49
+
50
+ [dependency-groups]
51
+ dev = [
52
+ "pytest>=8.0",
53
+ "pytest-asyncio>=0.24.0",
54
+ "pytest-xdist>=3.6.1",
55
+ "pytest-json-report>=1.5.0",
56
+ "python-dotenv",
57
+ "requests>=2.32.3",
58
+ "flake8>=7.0",
59
+ "pytest-timeout>=2.3.1",
60
+ "ruff>=0.9.9",
61
+ "pytest-benchmark>=4.0.0",
62
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,19 @@
1
+ from .engine import ClickHouseEngine, clickhouse_engine
2
+ from .session import ClickHouseSession
3
+
4
+
5
+ def register() -> None:
6
+ """Entry-point hook invoked by tigrbl to register the engine kind."""
7
+ try:
8
+ from tigrbl.engine.registry import register_engine
9
+ except Exception: # pragma: no cover
10
+ from tigrbl.engine import register_engine # type: ignore
11
+ register_engine("clickhouse", clickhouse_engine)
12
+
13
+
14
+ __all__ = [
15
+ "ClickHouseEngine",
16
+ "ClickHouseSession",
17
+ "clickhouse_engine",
18
+ "register",
19
+ ]
@@ -0,0 +1,63 @@
1
+ from __future__ import annotations
2
+ from typing import Any, Callable, Tuple, Mapping, Optional
3
+
4
+ from tigrbl.engine._engine import Engine # first-class engine façade
5
+ from .session import ClickHouseSession
6
+
7
+
8
+ class ClickHouseEngine(Engine):
9
+ """Thin handle for ClickHouse connectivity parameters.
10
+
11
+ Subclasses tigrbl's first-class :class:`Engine` for parity with built-ins.
12
+ The session owns the actual driver client.
13
+ """
14
+
15
+ def __init__(
16
+ self,
17
+ *,
18
+ url: Optional[str] = None,
19
+ host: Optional[str] = None,
20
+ port: Optional[int] = None,
21
+ username: Optional[str] = None,
22
+ password: Optional[str] = None,
23
+ database: Optional[str] = None,
24
+ secure: Optional[bool] = None,
25
+ verify: Optional[bool] = None,
26
+ **kwargs: Any,
27
+ ) -> None:
28
+ self.url = url
29
+ self.host = host or "localhost"
30
+ self.port = int(port or 8123)
31
+ self.username = username or "default"
32
+ self.password = password or ""
33
+ self.database = database or "default"
34
+ self.secure = bool(secure) if secure is not None else False
35
+ self.verify = bool(verify) if verify is not None else True
36
+ self.kwargs = dict(kwargs)
37
+
38
+
39
+ def clickhouse_engine(
40
+ *,
41
+ mapping: Optional[Mapping[str, object]] = None,
42
+ spec: Any = None,
43
+ dsn: Optional[str] = None,
44
+ **kwargs: Any,
45
+ ) -> Tuple[ClickHouseEngine, Callable[[], Any]]:
46
+ """Builder used by tigrbl to construct (engine, session_factory)."""
47
+ m = dict(mapping or {})
48
+ engine = ClickHouseEngine(
49
+ url=dsn or m.get("url") or kwargs.get("url"),
50
+ host=m.get("host") or kwargs.get("host"),
51
+ port=m.get("port") or kwargs.get("port"),
52
+ username=m.get("username") or kwargs.get("username"),
53
+ password=m.get("password") or kwargs.get("password"),
54
+ database=m.get("database") or kwargs.get("database"),
55
+ secure=m.get("secure") or kwargs.get("secure"),
56
+ verify=m.get("verify") or kwargs.get("verify"),
57
+ **kwargs,
58
+ )
59
+
60
+ def session_factory() -> ClickHouseSession:
61
+ return ClickHouseSession(engine)
62
+
63
+ return engine, session_factory
@@ -0,0 +1,114 @@
1
+ from __future__ import annotations
2
+ from typing import Any, Optional
3
+
4
+ from tigrbl.session.base import TigrblSessionBase # first-class session base
5
+
6
+
7
+ class ClickHouseSession(TigrblSessionBase):
8
+ """A Tigrbl session backed by clickhouse-connect (sync client).
9
+
10
+ This concrete session implements the async hooks expected by
11
+ :class:`TigrblSessionBase`. ClickHouse does not provide general-purpose
12
+ transactions; the tx hooks are treated as no-ops.
13
+ """
14
+
15
+ def __init__(self, engine: Any, *, url: Optional[str] = None) -> None:
16
+ super().__init__()
17
+ self._engine = engine
18
+ self._url_override = url
19
+ self._client = None
20
+
21
+ # ---- client lifecycle -------------------------------------------------
22
+ @property
23
+ def client(self):
24
+ if self._client is None:
25
+ try:
26
+ import clickhouse_connect
27
+ except Exception as e: # pragma: no cover
28
+ raise RuntimeError(
29
+ "clickhouse-connect is required for ClickHouseSession"
30
+ ) from e
31
+
32
+ if self._url_override or self._engine.url:
33
+ # clickhouse-connect supports URL form
34
+ self._client = clickhouse_connect.get_client(
35
+ url=self._url_override or self._engine.url
36
+ )
37
+ else:
38
+ self._client = clickhouse_connect.get_client(
39
+ host=self._engine.host,
40
+ port=self._engine.port,
41
+ username=self._engine.username,
42
+ password=self._engine.password,
43
+ database=self._engine.database,
44
+ secure=self._engine.secure,
45
+ verify=self._engine.verify,
46
+ **self._engine.kwargs,
47
+ )
48
+ return self._client
49
+
50
+ # ---- TigrblSessionBase hooks -----------------------------------------
51
+ async def _tx_begin_impl(self) -> None: # no-op; ClickHouse has limited tx support
52
+ return None
53
+
54
+ async def _tx_commit_impl(self) -> None:
55
+ return None
56
+
57
+ async def _tx_rollback_impl(self) -> None:
58
+ return None
59
+
60
+ def _add_impl(self, obj: Any) -> Any:
61
+ raise NotImplementedError(
62
+ "ClickHouseSession.add is not supported; use _execute_impl with INSERT"
63
+ )
64
+
65
+ async def _delete_impl(self, obj: Any) -> None:
66
+ raise NotImplementedError(
67
+ "ClickHouseSession.delete is not supported; use _execute_impl with DELETE"
68
+ )
69
+
70
+ async def _flush_impl(self) -> None:
71
+ # No buffering by default
72
+ return None
73
+
74
+ async def _refresh_impl(self, obj: Any) -> None:
75
+ return None
76
+
77
+ async def _get_impl(self, model: type, ident: Any) -> Any | None:
78
+ # Generic ORM-style get is not applicable; return None
79
+ return None
80
+
81
+ async def _execute_impl(self, stmt: Any) -> Any:
82
+ """Execute a SQL statement.
83
+
84
+ - If `stmt` is a string, route SELECT-like statements to `query()`,
85
+ others to `command()`.
86
+ - If `stmt` is a callable, call it with the underlying client.
87
+ """
88
+ if callable(stmt):
89
+ return stmt(self.client)
90
+
91
+ if not isinstance(stmt, str):
92
+ raise NotImplementedError(
93
+ f"Unsupported stmt type: {type(stmt)}; expected SQL string or callable"
94
+ )
95
+
96
+ sql = stmt.strip()
97
+ # Heuristic: treat SELECT/SHOW/DESCRIBE/EXPLAIN as queries
98
+ prefix = sql.split(None, 1)[0].upper() if sql else ""
99
+ if prefix in {"SELECT", "WITH", "SHOW", "DESCRIBE", "EXPLAIN"}:
100
+ res = self.client.query(sql)
101
+ # Return rows (list of tuples). Caller can access names via res.column_names
102
+ try:
103
+ return res.result_rows # clickhouse-connect 0.6+
104
+ except Exception:
105
+ return getattr(res, "rows", res)
106
+ else:
107
+ return self.client.command(sql)
108
+
109
+ async def _close_impl(self) -> None:
110
+ if self._client is not None:
111
+ try:
112
+ self._client.close()
113
+ finally:
114
+ self._client = None
@@ -0,0 +1,71 @@
1
+ Metadata-Version: 2.4
2
+ Name: tigrbl_engine_clickhouse
3
+ Version: 0.1.1.dev2
4
+ Summary: Tigrbl engine plugin providing ClickHouse database support.
5
+ Author-email: Jacob Stewart <jacob@swarmauri.com>
6
+ License: Apache-2.0
7
+ Keywords: tigrbl,engine,plugin,clickhouse,database,analytics
8
+ Classifier: Development Status :: 1 - Planning
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Programming Language :: Python
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Environment :: Plugins
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: Topic :: Database
19
+ Classifier: Topic :: Software Development :: Libraries
20
+ Requires-Python: <3.13,>=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: tigrbl>=0.3.0.dev4
24
+ Requires-Dist: clickhouse-connect>=0.6.0
25
+ Dynamic: license-file
26
+
27
+ # tigrbl_engine_clickhouse
28
+
29
+ A ClickHouse engine plugin for **tigrbl**. This package registers a new engine
30
+ kind `"clickhouse"` that tigrbl auto‑discovers via the `tigrbl.engine` entry‑point group.
31
+
32
+ > Both classes in this package are **subclasses of tigrbl's first‑class objects**.
33
+
34
+ ## Installation
35
+
36
+ ```bash
37
+ pip install tigrbl_engine_clickhouse
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ ```python
43
+ from tigrbl.engine.engine_spec import EngineSpec
44
+
45
+ spec = EngineSpec(kind="clickhouse", mapping={
46
+ "host": "localhost",
47
+ "port": 8123,
48
+ "username": "default",
49
+ "password": "",
50
+ "database": "default",
51
+ "secure": False,
52
+ })
53
+ eng, make_session = spec.build() # resolved via entry-points
54
+ s = make_session() # returns a ClickHouseSession (TigrblSessionBase subclass)
55
+
56
+ # Example query
57
+ rows = await s._execute_impl("SELECT 1 AS x")
58
+ print(rows)
59
+ await s.close()
60
+ ```
61
+
62
+ ### How it’s wired
63
+
64
+ - `pyproject.toml` declares the entry‑point:
65
+ ```toml
66
+ [project.entry-points."tigrbl.engine"]
67
+ clickhouse = "tigrbl_engine_clickhouse:register"
68
+ ```
69
+ - `register()` (in `__init__.py`) calls `tigrbl.engine.registry.register_engine("clickhouse", clickhouse_engine)`.
70
+ - `ClickHouseEngine` subclasses `tigrbl.engine._engine.Engine`.
71
+ - `ClickHouseSession` subclasses `tigrbl.session.base.TigrblSessionBase` and uses `clickhouse_connect`.
@@ -0,0 +1,13 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/tigrbl_engine_clickhouse/__init__.py
5
+ src/tigrbl_engine_clickhouse/engine.py
6
+ src/tigrbl_engine_clickhouse/session.py
7
+ src/tigrbl_engine_clickhouse.egg-info/PKG-INFO
8
+ src/tigrbl_engine_clickhouse.egg-info/SOURCES.txt
9
+ src/tigrbl_engine_clickhouse.egg-info/dependency_links.txt
10
+ src/tigrbl_engine_clickhouse.egg-info/entry_points.txt
11
+ src/tigrbl_engine_clickhouse.egg-info/requires.txt
12
+ src/tigrbl_engine_clickhouse.egg-info/top_level.txt
13
+ tests/test_smoke.py
@@ -0,0 +1,2 @@
1
+ [tigrbl.engine]
2
+ clickhouse = tigrbl_engine_clickhouse:register
@@ -0,0 +1,2 @@
1
+ tigrbl>=0.3.0.dev4
2
+ clickhouse-connect>=0.6.0
@@ -0,0 +1,8 @@
1
+ from pathlib import Path
2
+
3
+
4
+ def test_package_assets_present() -> None:
5
+ package_dir = Path(__file__).resolve().parents[1]
6
+ assert (package_dir / "README.md").is_file()
7
+ assert (package_dir / "LICENSE").is_file()
8
+ assert (package_dir / "pyproject.toml").is_file()