mapepire-python 1.0.1__tar.gz → 2.0.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.
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/PKG-INFO +22 -2
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/README.md +19 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/async_base_job.py +22 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/client/query.py +18 -3
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/client/sql_job.py +24 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/core/cursor.py +14 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/data_types.py +28 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/pool/pool_query.py +14 -2
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/version.py +2 -2
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python.egg-info/PKG-INFO +22 -2
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python.egg-info/requires.txt +2 -1
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/pyproject.toml +2 -1
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/LICENSE +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/__init__.py +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/asyncio/__init__.py +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/asyncio/connection.py +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/asyncio/cursor.py +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/authentication/kerberosTokenProvider.py +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/base_job.py +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/client/__init__.py +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/client/async_sql_job.py +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/client/websocket_client.py +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/core/__init__.py +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/core/connection.py +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/core/exceptions.py +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/core/utils.py +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/pool/__init__.py +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/pool/async_websocket_client.py +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/pool/pool_client.py +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/pool/pool_job.py +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/py.typed +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/query_manager.py +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/ssl.py +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/websocket.py +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python.egg-info/SOURCES.txt +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python.egg-info/dependency_links.txt +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python.egg-info/top_level.txt +0 -0
- {mapepire_python-1.0.1 → mapepire_python-2.0.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mapepire-python
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.0
|
|
4
4
|
Author-email: Adam Shedivy <adam.shedivy@ibm.com>, Irfan Sharif <IrfanSharif@ibm.com>
|
|
5
5
|
License: Apache License
|
|
6
6
|
Version 2.0, January 2004
|
|
@@ -225,7 +225,7 @@ Requires-Dist: pywin32; sys_platform == "win32" and extra == "kerberos"
|
|
|
225
225
|
Provides-Extra: dev
|
|
226
226
|
Requires-Dist: ruff<0.16,>=0.15; extra == "dev"
|
|
227
227
|
Requires-Dist: mypy<2.4,>=1.0; extra == "dev"
|
|
228
|
-
Requires-Dist: black<27.0,>=
|
|
228
|
+
Requires-Dist: black<27.0,>=26.10.0; extra == "dev"
|
|
229
229
|
Requires-Dist: isort<8.1,>=5.12; extra == "dev"
|
|
230
230
|
Requires-Dist: pytest>=9.0.3; extra == "dev"
|
|
231
231
|
Requires-Dist: pep249abc; extra == "dev"
|
|
@@ -237,6 +237,7 @@ Requires-Dist: setuptools; extra == "dev"
|
|
|
237
237
|
Requires-Dist: wheel; extra == "dev"
|
|
238
238
|
Requires-Dist: packaging; extra == "dev"
|
|
239
239
|
Requires-Dist: pre-commit; extra == "dev"
|
|
240
|
+
Requires-Dist: virtualenv>=21.15.0; extra == "dev"
|
|
240
241
|
Requires-Dist: python-dotenv; extra == "dev"
|
|
241
242
|
Requires-Dist: pytest-env; extra == "dev"
|
|
242
243
|
Dynamic: license-file
|
|
@@ -763,6 +764,25 @@ with SQLJob("./mapepire.ini") as sql_job:
|
|
|
763
764
|
print(result)
|
|
764
765
|
```
|
|
765
766
|
|
|
767
|
+
### Run CL commands
|
|
768
|
+
|
|
769
|
+
- `clcommand()` runs a CL command in the SQL job (`cl` request)
|
|
770
|
+
- `rcclcommand()` runs it in the remote command job (`rccl` request)
|
|
771
|
+
|
|
772
|
+
Both need Mapepire Server v2.5.0 or later, which added `rccl` and the message format these methods return.
|
|
773
|
+
|
|
774
|
+
```python
|
|
775
|
+
from mapepire_python import SQLJob
|
|
776
|
+
|
|
777
|
+
with SQLJob("./mapepire.ini") as sql_job:
|
|
778
|
+
result = sql_job.rcclcommand("CHKOBJ OBJ(QSYS) OBJTYPE(*LIB)")
|
|
779
|
+
print(result.success, result.data)
|
|
780
|
+
```
|
|
781
|
+
|
|
782
|
+
Both return a `CLCommandResult` whose `data` is the list of messages the command produced. A failed command returns `success=False` and `error` instead of raising. `PoolJob` has async versions of both methods.
|
|
783
|
+
|
|
784
|
+
CL commands can also go through `query()` with `QueryOptions(isClCommand=True)` or `QueryOptions(isRemoteClCommand=True)`, or through the sync PEP 249 `Cursor` with `cursor.execute(cmd, isRemoteClCommand=True)`.
|
|
785
|
+
|
|
766
786
|
## 2. Using the `PoolJob` object to run queries asynchronously
|
|
767
787
|
|
|
768
788
|
The `PoolJob` object can be used to create and run queries asynchronously:
|
|
@@ -520,6 +520,25 @@ with SQLJob("./mapepire.ini") as sql_job:
|
|
|
520
520
|
print(result)
|
|
521
521
|
```
|
|
522
522
|
|
|
523
|
+
### Run CL commands
|
|
524
|
+
|
|
525
|
+
- `clcommand()` runs a CL command in the SQL job (`cl` request)
|
|
526
|
+
- `rcclcommand()` runs it in the remote command job (`rccl` request)
|
|
527
|
+
|
|
528
|
+
Both need Mapepire Server v2.5.0 or later, which added `rccl` and the message format these methods return.
|
|
529
|
+
|
|
530
|
+
```python
|
|
531
|
+
from mapepire_python import SQLJob
|
|
532
|
+
|
|
533
|
+
with SQLJob("./mapepire.ini") as sql_job:
|
|
534
|
+
result = sql_job.rcclcommand("CHKOBJ OBJ(QSYS) OBJTYPE(*LIB)")
|
|
535
|
+
print(result.success, result.data)
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
Both return a `CLCommandResult` whose `data` is the list of messages the command produced. A failed command returns `success=False` and `error` instead of raising. `PoolJob` has async versions of both methods.
|
|
539
|
+
|
|
540
|
+
CL commands can also go through `query()` with `QueryOptions(isClCommand=True)` or `QueryOptions(isRemoteClCommand=True)`, or through the sync PEP 249 `Cursor` with `cursor.execute(cmd, isRemoteClCommand=True)`.
|
|
541
|
+
|
|
523
542
|
## 2. Using the `PoolJob` object to run queries asynchronously
|
|
524
543
|
|
|
525
544
|
The `PoolJob` object can be used to create and run queries asynchronously:
|
|
@@ -10,11 +10,15 @@ from websockets.asyncio.client import ClientConnection
|
|
|
10
10
|
|
|
11
11
|
from .base_job import BaseJob
|
|
12
12
|
from .data_types import (
|
|
13
|
+
BaseRequest,
|
|
14
|
+
CLCommandResult,
|
|
15
|
+
ClRequest,
|
|
13
16
|
ConnectionResult,
|
|
14
17
|
ConnectRequest,
|
|
15
18
|
DaemonServer,
|
|
16
19
|
JobStatus,
|
|
17
20
|
QueryOptions,
|
|
21
|
+
RcclRequest,
|
|
18
22
|
)
|
|
19
23
|
|
|
20
24
|
__all__ = ["AsyncBaseJob"]
|
|
@@ -209,6 +213,24 @@ class AsyncBaseJob(BaseJob):
|
|
|
209
213
|
except Exception as e:
|
|
210
214
|
raise RuntimeError(f"Failed to run query: {e}") from e
|
|
211
215
|
|
|
216
|
+
async def clcommand(self, cmd: str) -> CLCommandResult:
|
|
217
|
+
"""Run a CL command in the SQL job (``cl``)."""
|
|
218
|
+
return await self._run_cl_command(cmd, remote=False)
|
|
219
|
+
|
|
220
|
+
async def rcclcommand(self, cmd: str) -> CLCommandResult:
|
|
221
|
+
"""Run a CL command in the remote command job (``rccl``, Mapepire Server v2.5.0+)."""
|
|
222
|
+
return await self._run_cl_command(cmd, remote=True)
|
|
223
|
+
|
|
224
|
+
async def _run_cl_command(self, cmd: str, remote: bool) -> CLCommandResult:
|
|
225
|
+
request: BaseRequest = (
|
|
226
|
+
RcclRequest(id=self._get_unique_id("rcclcommand"), cmd=cmd)
|
|
227
|
+
if remote
|
|
228
|
+
else ClRequest(id=self._get_unique_id("clcommand"), cmd=cmd)
|
|
229
|
+
)
|
|
230
|
+
return CLCommandResult.from_dict( # type: ignore[attr-defined]
|
|
231
|
+
await self.send(json.dumps(dataclasses.asdict(request)))
|
|
232
|
+
)
|
|
233
|
+
|
|
212
234
|
async def close(self) -> None: # type: ignore[override]
|
|
213
235
|
logger.info("Closing job %s", self.id)
|
|
214
236
|
await self.dispose()
|
|
@@ -12,6 +12,7 @@ from ..data_types import (
|
|
|
12
12
|
PrepareSqlExecuteRequest,
|
|
13
13
|
QueryOptions,
|
|
14
14
|
QueryResult,
|
|
15
|
+
RcclRequest,
|
|
15
16
|
SqlCloseRequest,
|
|
16
17
|
SqlCloseResponse,
|
|
17
18
|
SqlMoreRequest,
|
|
@@ -40,7 +41,8 @@ class Query(Generic[T]):
|
|
|
40
41
|
self.sql: str = query
|
|
41
42
|
self.is_prepared: bool = True if opts.parameters is not None else False
|
|
42
43
|
self.parameters: Union[Sequence[Any], Mapping[Union[str, int], Any]] = opts.parameters if opts.parameters is not None else []
|
|
43
|
-
self.
|
|
44
|
+
self.is_remote_cl_command: Optional[bool] = opts.isRemoteClCommand
|
|
45
|
+
self.is_cl_command: Optional[bool] = opts.isClCommand or opts.isRemoteClCommand
|
|
44
46
|
self.should_auto_close: Optional[bool] = opts.autoClose
|
|
45
47
|
self.is_terse_results: Optional[bool] = opts.isTerseResults
|
|
46
48
|
|
|
@@ -71,6 +73,9 @@ class Query(Generic[T]):
|
|
|
71
73
|
if self.state == QueryState.RUN_DONE:
|
|
72
74
|
raise Exception("Statement has already been fully run")
|
|
73
75
|
|
|
76
|
+
if self.is_cl_command:
|
|
77
|
+
return self.run()
|
|
78
|
+
|
|
74
79
|
logger.debug("Preparing and executing query")
|
|
75
80
|
query_result = QueryResult.from_dict( # type: ignore
|
|
76
81
|
self._execute_query(
|
|
@@ -83,7 +88,7 @@ class Query(Generic[T]):
|
|
|
83
88
|
)
|
|
84
89
|
self.state = QueryState.RUN_DONE if query_result.is_done else QueryState.RUN_MORE_DATA_AVAIL
|
|
85
90
|
|
|
86
|
-
if not query_result.success
|
|
91
|
+
if not query_result.success:
|
|
87
92
|
self.state = QueryState.ERROR
|
|
88
93
|
error_list = {k: v for k, v in {"error": query_result.error, "sql_state": query_result.sql_state, "sql_rc": query_result.sql_rc}.items() if v}
|
|
89
94
|
if not error_list:
|
|
@@ -111,7 +116,13 @@ class Query(Generic[T]):
|
|
|
111
116
|
|
|
112
117
|
logger.debug("Executing query: rows_to_fetch=%s", rows_to_fetch)
|
|
113
118
|
|
|
114
|
-
|
|
119
|
+
request: BaseRequest
|
|
120
|
+
if self.is_remote_cl_command:
|
|
121
|
+
request = RcclRequest(
|
|
122
|
+
id=self.job._get_unique_id("rcclcommand"),
|
|
123
|
+
cmd=self.sql,
|
|
124
|
+
)
|
|
125
|
+
elif self.is_cl_command:
|
|
115
126
|
request = ClRequest(
|
|
116
127
|
id=self.job._get_unique_id("clcommand"),
|
|
117
128
|
cmd=self.sql,
|
|
@@ -136,6 +147,10 @@ class Query(Generic[T]):
|
|
|
136
147
|
|
|
137
148
|
query_result = QueryResult.from_dict(self._execute_query(request)) # type: ignore
|
|
138
149
|
|
|
150
|
+
# CL commands return all messages in one response; mapepire-server 2.5.0+ omits is_done for them
|
|
151
|
+
if self.is_cl_command:
|
|
152
|
+
query_result.is_done = True
|
|
153
|
+
|
|
139
154
|
self.state = QueryState.RUN_DONE if query_result.is_done else QueryState.RUN_MORE_DATA_AVAIL
|
|
140
155
|
|
|
141
156
|
if not query_result.success and not self.is_cl_command:
|
|
@@ -11,11 +11,15 @@ from mapepire_python.websocket import handle_ws_errors
|
|
|
11
11
|
|
|
12
12
|
from ..base_job import BaseJob
|
|
13
13
|
from ..data_types import (
|
|
14
|
+
BaseRequest,
|
|
15
|
+
CLCommandResult,
|
|
16
|
+
ClRequest,
|
|
14
17
|
ConnectionResult,
|
|
15
18
|
ConnectRequest,
|
|
16
19
|
DaemonServer,
|
|
17
20
|
JobStatus,
|
|
18
21
|
QueryOptions,
|
|
22
|
+
RcclRequest,
|
|
19
23
|
)
|
|
20
24
|
|
|
21
25
|
__all__ = ["SQLJob"]
|
|
@@ -202,6 +206,26 @@ class SQLJob(BaseJob):
|
|
|
202
206
|
except Exception as e:
|
|
203
207
|
raise RuntimeError(f"Failed to run query: {e}")
|
|
204
208
|
|
|
209
|
+
def clcommand(self, cmd: str) -> CLCommandResult:
|
|
210
|
+
"""Run a CL command in the SQL job (``cl``)."""
|
|
211
|
+
return self._run_cl_command(cmd, remote=False)
|
|
212
|
+
|
|
213
|
+
def rcclcommand(self, cmd: str) -> CLCommandResult:
|
|
214
|
+
"""Run a CL command in the remote command job (``rccl``, Mapepire Server v2.5.0+)."""
|
|
215
|
+
return self._run_cl_command(cmd, remote=True)
|
|
216
|
+
|
|
217
|
+
@handle_ws_errors
|
|
218
|
+
def _run_cl_command(self, cmd: str, remote: bool) -> CLCommandResult:
|
|
219
|
+
request: BaseRequest = (
|
|
220
|
+
RcclRequest(id=self._get_unique_id("rcclcommand"), cmd=cmd)
|
|
221
|
+
if remote
|
|
222
|
+
else ClRequest(id=self._get_unique_id("clcommand"), cmd=cmd)
|
|
223
|
+
)
|
|
224
|
+
self.send(json.dumps(dataclasses.asdict(request)))
|
|
225
|
+
if self._socket is None:
|
|
226
|
+
raise RuntimeError("SQL Job not connected")
|
|
227
|
+
return CLCommandResult.from_dict(json.loads(self._socket.recv())) # type: ignore
|
|
228
|
+
|
|
205
229
|
def close(self) -> None:
|
|
206
230
|
logger.info("Closing job %s", self.id)
|
|
207
231
|
self._status = JobStatus.Ended
|
|
@@ -121,6 +121,7 @@ class Cursor(pep249.CursorConnectionMixin, pep249.IterableCursorMixin, pep249.Tr
|
|
|
121
121
|
else:
|
|
122
122
|
create_opts = QueryOptions(
|
|
123
123
|
isClCommand=kwargs.get("isClCommand", None),
|
|
124
|
+
isRemoteClCommand=kwargs.get("isRemoteClCommand", None),
|
|
124
125
|
isTerseResults=kwargs.get("isTerseResults", None),
|
|
125
126
|
parameters=parameters if parameters else None,
|
|
126
127
|
autoClose=kwargs.get("autoclose", None),
|
|
@@ -128,6 +129,19 @@ class Cursor(pep249.CursorConnectionMixin, pep249.IterableCursorMixin, pep249.Tr
|
|
|
128
129
|
|
|
129
130
|
query = Query(self.job, operation, create_opts)
|
|
130
131
|
|
|
132
|
+
if query.is_cl_command:
|
|
133
|
+
# CL commands return messages, not rows, and Query.run() does not raise when they fail.
|
|
134
|
+
cl_result = query.run()
|
|
135
|
+
self.query = None
|
|
136
|
+
self._metadata = None
|
|
137
|
+
self.__set_has_results(False)
|
|
138
|
+
self.rowcount = -1
|
|
139
|
+
if not cl_result["success"]:
|
|
140
|
+
raise RuntimeError(
|
|
141
|
+
{"error": cl_result["error"] or "CL command failed for unknown reason"}
|
|
142
|
+
)
|
|
143
|
+
return self
|
|
144
|
+
|
|
131
145
|
prepare_result = query.prepare_sql_execute()
|
|
132
146
|
|
|
133
147
|
qs = QueryResultSet(prepare_result)
|
|
@@ -73,6 +73,7 @@ class MessageType(Enum):
|
|
|
73
73
|
SQL_MORE = "sqlmore"
|
|
74
74
|
SQL_CLOSE = "sqlclose"
|
|
75
75
|
CL = "cl"
|
|
76
|
+
RCCL = "rccl"
|
|
76
77
|
PING = "ping"
|
|
77
78
|
GET_DB_JOB = "getdbjob"
|
|
78
79
|
GET_VERSION = "getversion"
|
|
@@ -316,9 +317,28 @@ class JobLogEntry:
|
|
|
316
317
|
MESSAGE_SECOND_LEVEL_TEXT: str
|
|
317
318
|
|
|
318
319
|
|
|
320
|
+
@dataclass
|
|
321
|
+
class CLMessage:
|
|
322
|
+
id: Optional[str] = None
|
|
323
|
+
type: Optional[str] = None
|
|
324
|
+
severity: Optional[int] = None
|
|
325
|
+
text: Optional[str] = None
|
|
326
|
+
help: Optional[str] = None
|
|
327
|
+
time: Optional[int] = None
|
|
328
|
+
messageLibrary: Optional[str] = None
|
|
329
|
+
messageFile: Optional[str] = None
|
|
330
|
+
sendingProgram: Optional[str] = None
|
|
331
|
+
sendingInstruction: Optional[str] = None
|
|
332
|
+
receivingProgram: Optional[str] = None
|
|
333
|
+
receivingInstruction: Optional[str] = None
|
|
334
|
+
|
|
335
|
+
|
|
319
336
|
@dataclass_json
|
|
320
337
|
@dataclass
|
|
321
338
|
class CLCommandResult(ServerResponse):
|
|
339
|
+
# sql_rc and sql_state are only set by `cl` requests; `rccl` does not run SQL.
|
|
340
|
+
data: List[CLMessage] = field(default_factory=list)
|
|
341
|
+
# Deprecated: no longer sent by Mapepire Server, kept for backwards compatibility
|
|
322
342
|
joblog: List[JobLogEntry] = field(default_factory=list)
|
|
323
343
|
|
|
324
344
|
|
|
@@ -328,6 +348,8 @@ class QueryOptions:
|
|
|
328
348
|
isClCommand: Optional[bool] = None
|
|
329
349
|
parameters: Optional[Union[Sequence[Any], Mapping[Union[str, int], Any]]] = None
|
|
330
350
|
autoClose: Optional[bool] = None
|
|
351
|
+
# `rccl` instead of `cl` (Mapepire Server v2.5.0+); implies isClCommand
|
|
352
|
+
isRemoteClCommand: Optional[bool] = None
|
|
331
353
|
|
|
332
354
|
|
|
333
355
|
@dataclass_json
|
|
@@ -406,6 +428,12 @@ class ClRequest(BaseRequest):
|
|
|
406
428
|
type: str = field(default=MessageType.CL.value, init=False)
|
|
407
429
|
|
|
408
430
|
|
|
431
|
+
@dataclass
|
|
432
|
+
class RcclRequest(BaseRequest):
|
|
433
|
+
cmd: str = ""
|
|
434
|
+
type: str = field(default=MessageType.RCCL.value, init=False)
|
|
435
|
+
|
|
436
|
+
|
|
409
437
|
@dataclass
|
|
410
438
|
class PingRequest(BaseRequest):
|
|
411
439
|
type: str = field(default=MessageType.PING.value, init=False)
|
|
@@ -10,6 +10,7 @@ from mapepire_python.data_types import (
|
|
|
10
10
|
PrepareSqlExecuteRequest,
|
|
11
11
|
QueryOptions,
|
|
12
12
|
QueryResult,
|
|
13
|
+
RcclRequest,
|
|
13
14
|
SqlCloseRequest,
|
|
14
15
|
SqlCloseResponse,
|
|
15
16
|
SqlMoreRequest,
|
|
@@ -42,7 +43,8 @@ class PoolQuery:
|
|
|
42
43
|
self.sql: str = query
|
|
43
44
|
self.is_prepared: bool = True if opts.parameters is not None else False
|
|
44
45
|
self.parameters: Optional[Union[Sequence[Any], Mapping[Union[str, int], Any]]] = opts.parameters
|
|
45
|
-
self.
|
|
46
|
+
self.is_remote_cl_command: Optional[bool] = opts.isRemoteClCommand
|
|
47
|
+
self.is_cl_command: Optional[bool] = opts.isClCommand or opts.isRemoteClCommand
|
|
46
48
|
self.should_auto_close: Optional[bool] = opts.autoClose
|
|
47
49
|
self.is_terse_results: Optional[bool] = opts.isTerseResults
|
|
48
50
|
|
|
@@ -76,7 +78,13 @@ class PoolQuery:
|
|
|
76
78
|
|
|
77
79
|
logger.debug("Executing async query: rows_to_fetch=%s", rows_to_fetch)
|
|
78
80
|
|
|
79
|
-
|
|
81
|
+
request: BaseRequest
|
|
82
|
+
if self.is_remote_cl_command:
|
|
83
|
+
request = RcclRequest(
|
|
84
|
+
id=self.job._get_unique_id("rcclcommand"),
|
|
85
|
+
cmd=self.sql,
|
|
86
|
+
)
|
|
87
|
+
elif self.is_cl_command:
|
|
80
88
|
request = ClRequest(
|
|
81
89
|
id=self.job._get_unique_id("clcommand"),
|
|
82
90
|
cmd=self.sql,
|
|
@@ -101,6 +109,10 @@ class PoolQuery:
|
|
|
101
109
|
|
|
102
110
|
query_result = QueryResult.from_dict(await self._execute_query(request)) # type: ignore
|
|
103
111
|
|
|
112
|
+
# CL commands return all messages in one response; mapepire-server 2.5.0+ omits is_done for them
|
|
113
|
+
if self.is_cl_command:
|
|
114
|
+
query_result.is_done = True
|
|
115
|
+
|
|
104
116
|
self.state = QueryState.RUN_DONE if query_result.is_done else QueryState.RUN_MORE_DATA_AVAIL
|
|
105
117
|
|
|
106
118
|
if not query_result.success and not self.is_cl_command:
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
_MAJOR = "
|
|
1
|
+
_MAJOR = "2"
|
|
2
2
|
_MINOR = "0"
|
|
3
3
|
# On main and in a nightly release the patch should be one ahead of the last
|
|
4
4
|
# released build.
|
|
5
|
-
_PATCH = "
|
|
5
|
+
_PATCH = "0"
|
|
6
6
|
# This is mainly for nightly builds which have the suffix ".dev$DATE". See
|
|
7
7
|
# https://semver.org/#is-v123-a-semantic-version for the semantics.
|
|
8
8
|
_SUFFIX = ""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mapepire-python
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.0
|
|
4
4
|
Author-email: Adam Shedivy <adam.shedivy@ibm.com>, Irfan Sharif <IrfanSharif@ibm.com>
|
|
5
5
|
License: Apache License
|
|
6
6
|
Version 2.0, January 2004
|
|
@@ -225,7 +225,7 @@ Requires-Dist: pywin32; sys_platform == "win32" and extra == "kerberos"
|
|
|
225
225
|
Provides-Extra: dev
|
|
226
226
|
Requires-Dist: ruff<0.16,>=0.15; extra == "dev"
|
|
227
227
|
Requires-Dist: mypy<2.4,>=1.0; extra == "dev"
|
|
228
|
-
Requires-Dist: black<27.0,>=
|
|
228
|
+
Requires-Dist: black<27.0,>=26.10.0; extra == "dev"
|
|
229
229
|
Requires-Dist: isort<8.1,>=5.12; extra == "dev"
|
|
230
230
|
Requires-Dist: pytest>=9.0.3; extra == "dev"
|
|
231
231
|
Requires-Dist: pep249abc; extra == "dev"
|
|
@@ -237,6 +237,7 @@ Requires-Dist: setuptools; extra == "dev"
|
|
|
237
237
|
Requires-Dist: wheel; extra == "dev"
|
|
238
238
|
Requires-Dist: packaging; extra == "dev"
|
|
239
239
|
Requires-Dist: pre-commit; extra == "dev"
|
|
240
|
+
Requires-Dist: virtualenv>=21.15.0; extra == "dev"
|
|
240
241
|
Requires-Dist: python-dotenv; extra == "dev"
|
|
241
242
|
Requires-Dist: pytest-env; extra == "dev"
|
|
242
243
|
Dynamic: license-file
|
|
@@ -763,6 +764,25 @@ with SQLJob("./mapepire.ini") as sql_job:
|
|
|
763
764
|
print(result)
|
|
764
765
|
```
|
|
765
766
|
|
|
767
|
+
### Run CL commands
|
|
768
|
+
|
|
769
|
+
- `clcommand()` runs a CL command in the SQL job (`cl` request)
|
|
770
|
+
- `rcclcommand()` runs it in the remote command job (`rccl` request)
|
|
771
|
+
|
|
772
|
+
Both need Mapepire Server v2.5.0 or later, which added `rccl` and the message format these methods return.
|
|
773
|
+
|
|
774
|
+
```python
|
|
775
|
+
from mapepire_python import SQLJob
|
|
776
|
+
|
|
777
|
+
with SQLJob("./mapepire.ini") as sql_job:
|
|
778
|
+
result = sql_job.rcclcommand("CHKOBJ OBJ(QSYS) OBJTYPE(*LIB)")
|
|
779
|
+
print(result.success, result.data)
|
|
780
|
+
```
|
|
781
|
+
|
|
782
|
+
Both return a `CLCommandResult` whose `data` is the list of messages the command produced. A failed command returns `success=False` and `error` instead of raising. `PoolJob` has async versions of both methods.
|
|
783
|
+
|
|
784
|
+
CL commands can also go through `query()` with `QueryOptions(isClCommand=True)` or `QueryOptions(isRemoteClCommand=True)`, or through the sync PEP 249 `Cursor` with `cursor.execute(cmd, isRemoteClCommand=True)`.
|
|
785
|
+
|
|
766
786
|
## 2. Using the `PoolJob` object to run queries asynchronously
|
|
767
787
|
|
|
768
788
|
The `PoolJob` object can be used to create and run queries asynchronously:
|
|
@@ -5,7 +5,7 @@ pep249abc
|
|
|
5
5
|
[dev]
|
|
6
6
|
ruff<0.16,>=0.15
|
|
7
7
|
mypy<2.4,>=1.0
|
|
8
|
-
black<27.0,>=
|
|
8
|
+
black<27.0,>=26.10.0
|
|
9
9
|
isort<8.1,>=5.12
|
|
10
10
|
pytest>=9.0.3
|
|
11
11
|
pep249abc
|
|
@@ -17,6 +17,7 @@ setuptools
|
|
|
17
17
|
wheel
|
|
18
18
|
packaging
|
|
19
19
|
pre-commit
|
|
20
|
+
virtualenv>=21.15.0
|
|
20
21
|
python-dotenv
|
|
21
22
|
pytest-env
|
|
22
23
|
|
|
@@ -40,7 +40,7 @@ kerberos = [
|
|
|
40
40
|
dev = [
|
|
41
41
|
"ruff>=0.15,<0.16",
|
|
42
42
|
"mypy>=1.0,<2.4",
|
|
43
|
-
"black>=
|
|
43
|
+
"black>=26.10.0,<27.0",
|
|
44
44
|
"isort>=5.12,<8.1",
|
|
45
45
|
"pytest>=9.0.3",
|
|
46
46
|
"pep249abc",
|
|
@@ -52,6 +52,7 @@ dev = [
|
|
|
52
52
|
"wheel",
|
|
53
53
|
"packaging",
|
|
54
54
|
"pre-commit",
|
|
55
|
+
"virtualenv>=21.15.0",
|
|
55
56
|
"python-dotenv",
|
|
56
57
|
"pytest-env",
|
|
57
58
|
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python/pool/async_websocket_client.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mapepire_python-1.0.1 → mapepire_python-2.0.0}/mapepire_python.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|