machbaseapi 2.0.0__py3-none-any.whl
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.
- machbaseAPI/__init__.py +32 -0
- machbaseAPI/connector.py +251 -0
- machbaseAPI/conntest.py +27 -0
- machbaseAPI/constants.py +189 -0
- machbaseAPI/errors.py +38 -0
- machbaseAPI/machbaseAPI.py +318 -0
- machbaseAPI/marshal.py +225 -0
- machbaseAPI/packet.py +87 -0
- machbaseAPI/protocol.py +661 -0
- machbaseAPI/sample/ConnTest.py +55 -0
- machbaseAPI/sample/MakeData.py +14 -0
- machbaseAPI/sample/Sample1Connect.py +27 -0
- machbaseAPI/sample/Sample2Simple.py +77 -0
- machbaseAPI/sample/Sample3Append.py +70 -0
- machbaseAPI/sample/Sample4Fetch.py +137 -0
- machbaseAPI/sample/Sample5Append2.py +81 -0
- machbaseAPI/sample/Sample5ConnectEx.py +57 -0
- machbaseAPI/sample/__init__.py +1 -0
- machbaseAPI/sample/data.txt +99 -0
- machbaseAPI/types.py +52 -0
- machbaseapi-2.0.0.dist-info/METADATA +121 -0
- machbaseapi-2.0.0.dist-info/RECORD +24 -0
- machbaseapi-2.0.0.dist-info/WHEEL +5 -0
- machbaseapi-2.0.0.dist-info/top_level.txt +1 -0
machbaseAPI/types.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import datetime
|
|
4
|
+
import ipaddress
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from . import constants as _C
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass(frozen=True)
|
|
12
|
+
class AppendType:
|
|
13
|
+
name: str
|
|
14
|
+
spiner_type: int
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def spiner_type_from_value(value: Any) -> int:
|
|
18
|
+
if value is None:
|
|
19
|
+
return _C.CMD_VARCHAR_TYPE
|
|
20
|
+
if isinstance(value, bool):
|
|
21
|
+
return _C.CMD_BOOL_TYPE
|
|
22
|
+
if isinstance(value, int):
|
|
23
|
+
if 0 <= value <= 0xFFFF:
|
|
24
|
+
return _C.CMD_UINT16_TYPE
|
|
25
|
+
if -(2 ** 15) <= value <= (2 ** 15) - 1:
|
|
26
|
+
return _C.CMD_INT16_TYPE
|
|
27
|
+
if 0 <= value <= 0xFFFFFFFF:
|
|
28
|
+
return _C.CMD_UINT32_TYPE
|
|
29
|
+
if -(2 ** 31) <= value <= (2 ** 31) - 1:
|
|
30
|
+
return _C.CMD_INT32_TYPE
|
|
31
|
+
if value >= 0:
|
|
32
|
+
return _C.CMD_UINT64_TYPE
|
|
33
|
+
return _C.CMD_INT64_TYPE
|
|
34
|
+
if isinstance(value, float):
|
|
35
|
+
return _C.CMD_FLT64_TYPE
|
|
36
|
+
if isinstance(value, (bytes, bytearray, memoryview)):
|
|
37
|
+
return _C.CMD_BINARY_TYPE
|
|
38
|
+
if isinstance(value, (datetime.datetime, datetime.date)):
|
|
39
|
+
return _C.CMD_DATE_TYPE
|
|
40
|
+
|
|
41
|
+
text = str(value)
|
|
42
|
+
if text:
|
|
43
|
+
try:
|
|
44
|
+
addr = ipaddress.ip_address(text)
|
|
45
|
+
return _C.CMD_IPV6_TYPE if addr.version == 6 else _C.CMD_IPV4_TYPE
|
|
46
|
+
except ValueError:
|
|
47
|
+
pass
|
|
48
|
+
return _C.CMD_VARCHAR_TYPE
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def spiner_type_from_legacy_sql(sql_type: int) -> int:
|
|
52
|
+
return _C.CMI_APPEND_TYPE_MAP.get(int(sql_type), _C.CMD_VARCHAR_TYPE)
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: machbaseapi
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Machbase Python API 2.0 (Pure Python, legacy compatible)
|
|
5
|
+
Home-page: http://www.machbase.com
|
|
6
|
+
Author: machbase
|
|
7
|
+
Author-email: support@machbase.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
11
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
12
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
13
|
+
Requires-Python: >=3.6
|
|
14
|
+
Description-Content-Type: text/plain
|
|
15
|
+
|
|
16
|
+
Copyright of this product 2013-2023,
|
|
17
|
+
Machbase Corporation(or Inc.) or its subsidiaries.
|
|
18
|
+
All Rights reserved.
|
|
19
|
+
|
|
20
|
+
http://www.machbase.com
|
|
21
|
+
|
|
22
|
+
support@machbase.com
|
|
23
|
+
|
|
24
|
+
Machbase Python API 2.0 (English introduction)
|
|
25
|
+
|
|
26
|
+
This package is a pure Python implementation of Machbase client protocol and provides a
|
|
27
|
+
drop-in replacement API compatible with the legacy Python API.
|
|
28
|
+
|
|
29
|
+
Key changes in version 2.0
|
|
30
|
+
|
|
31
|
+
1. Pure Python implementation
|
|
32
|
+
- Native binary libraries (`.so`, `.dylib`, `.dll`) are no longer required.
|
|
33
|
+
- Wire protocol, packet framing, and marshal/unmarshal logic are implemented in Python modules
|
|
34
|
+
(`protocol.py`, `marshal.py`, `packet.py`).
|
|
35
|
+
- Distribution is platform independent (`py3-none-any` wheel).
|
|
36
|
+
|
|
37
|
+
2. Fully compatible with existing interfaces
|
|
38
|
+
- Existing entry points are preserved (`machbase`, `machbaseAPI`, `connect`, `MachbaseConnection`, `MachbaseCursor`).
|
|
39
|
+
- Legacy call patterns for common operations are maintained for migration (`open`, `close`, `openEx`,
|
|
40
|
+
`execute`, `select`, `fetch`, `append`, DB-API cursor execution/fetch).
|
|
41
|
+
- Existing sample scripts and test code can be executed using the new package without adapter code.
|
|
42
|
+
- Existing behavior for unsupported features is preserved as explicit errors.
|
|
43
|
+
|
|
44
|
+
3. Improved append API
|
|
45
|
+
- Append payload handling accepts flexible row shapes in practical usage.
|
|
46
|
+
- `types` can be inferred from active append session and explicit type metadata.
|
|
47
|
+
- Async-friendly append path: callers can supply callbacks and receive protocol ack handling
|
|
48
|
+
without forcing unnecessary blocking.
|
|
49
|
+
- Improved row normalization and validation for mixed input forms.
|
|
50
|
+
|
|
51
|
+
4. Reliability and API strictness improvements
|
|
52
|
+
- Connection pooling is rejected with clear errors because pooling is intentionally not supported.
|
|
53
|
+
- Unknown connection options are rejected up front (fast validation).
|
|
54
|
+
- Expanded DB-API compatible exception mapping.
|
|
55
|
+
- Safer close/shutdown cleanup for sockets and sessions.
|
|
56
|
+
- Consistent internal encoding for bytes/binary-like values during legacy-style APIs.
|
|
57
|
+
|
|
58
|
+
5. Operational and migration notes
|
|
59
|
+
- Binary wheel no longer embeds platform native modules.
|
|
60
|
+
- Installation is lightweight and easier to mirror in CI/build pipelines.
|
|
61
|
+
- Version is updated to `2.0.0` (package revision for migration cycle).
|
|
62
|
+
|
|
63
|
+
What changed for users migrating from 1.x
|
|
64
|
+
|
|
65
|
+
- Connection
|
|
66
|
+
- Use the same host/port/user/password defaults as before.
|
|
67
|
+
- No `lib` copy or platform-specific package setup required.
|
|
68
|
+
- Append
|
|
69
|
+
- Existing `append` usage is supported; session-based and immediate append flows remain available.
|
|
70
|
+
- Compatibility boundaries
|
|
71
|
+
- Existing scripts that relied on hidden/undocumented native behaviors may need review.
|
|
72
|
+
- Pooling-related keys or unsupported options will now raise immediate errors (instead of being ignored).
|
|
73
|
+
|
|
74
|
+
Known limitations and troubleshooting
|
|
75
|
+
|
|
76
|
+
- Auto commit model
|
|
77
|
+
- Transactions are auto-commit by protocol design for this API.
|
|
78
|
+
- High-volume append
|
|
79
|
+
- Performance gains from batching large payloads are still recommended.
|
|
80
|
+
- For ultra-high throughput scenarios, tune client-side batching strategy in your application.
|
|
81
|
+
- Error handling
|
|
82
|
+
- Append/append_data and query errors are surfaced through return status and callbacks according to API layer.
|
|
83
|
+
|
|
84
|
+
FAQ
|
|
85
|
+
|
|
86
|
+
- Why only `py3-none-any`?
|
|
87
|
+
- The package does not load platform-specific binaries anymore.
|
|
88
|
+
- Where can I check differences from old binaries?
|
|
89
|
+
- Refer to `CHANGELOG.md` and API regression test suite in `test/regress`.
|
|
90
|
+
|
|
91
|
+
For full behavioral and compatibility reference, see `CHANGELOG.md` and the regression test set.
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# Changelog
|
|
95
|
+
|
|
96
|
+
## 2.0.0
|
|
97
|
+
|
|
98
|
+
### Changed
|
|
99
|
+
- Migrated to a pure Python implementation of Machbase protocol processing.
|
|
100
|
+
- Removed dependency on native dynamic libraries (`.so`, `.dll`, `.dylib`) from runtime package.
|
|
101
|
+
- Kept legacy API compatibility as the primary migration strategy:
|
|
102
|
+
- `machbase` and `machbaseAPI` legacy styles
|
|
103
|
+
- `connect`, `MachbaseConnection`, `MachbaseCursor`
|
|
104
|
+
- legacy sample script behavior for connection/query/append use cases
|
|
105
|
+
- Improved append handling:
|
|
106
|
+
- more flexible row normalization in session and one-shot append paths
|
|
107
|
+
- async-friendly acknowledgement callback flow
|
|
108
|
+
- stronger validation around row/type consistency
|
|
109
|
+
- Strengthened connection argument validation:
|
|
110
|
+
- pooling-related options are explicitly rejected
|
|
111
|
+
- unknown keyword options are rejected with clear error messages
|
|
112
|
+
|
|
113
|
+
### Fixed
|
|
114
|
+
- Unified protocol implementation path to Python-only marshal/packet parsing.
|
|
115
|
+
- Removed native bridge-related packaging behavior and binary cleanup assumptions.
|
|
116
|
+
- Reduced hidden binary cleanup side effects in build artifacts and packaging files.
|
|
117
|
+
|
|
118
|
+
### Notes
|
|
119
|
+
- Package version is set to `2.0.0`.
|
|
120
|
+
- Binary distribution format remains source-compatible with legacy test artifacts when using
|
|
121
|
+
`PYTHONPATH`-based execution.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
machbaseAPI/__init__.py,sha256=5HbjuttKoIlTOi8JGMhalhy06FbV0kYpgg3ITFT-orw,592
|
|
2
|
+
machbaseAPI/connector.py,sha256=GJriAl0EUrY4_lxNAdZRx8tVJo3Qs0kGr7-PSaZFL5Y,8089
|
|
3
|
+
machbaseAPI/conntest.py,sha256=zqzeq59hkg9ucIkejPwep-G0hMt5ISdByJkQJmO6uPg,732
|
|
4
|
+
machbaseAPI/constants.py,sha256=M4g-yX_u5rus0hO-hmTkutK9fw4IteNi6mF7fy2qLXs,5404
|
|
5
|
+
machbaseAPI/errors.py,sha256=WCKQj3LXM1H34xlM2orm1tlK7a4xpy1xZtxXJazP2Nc,795
|
|
6
|
+
machbaseAPI/machbaseAPI.py,sha256=mlrpUFB00FA0y4B26tdb8AfYSZCT_tQML4ZO7EljwQ8,11056
|
|
7
|
+
machbaseAPI/marshal.py,sha256=sXrdNxe4WEhz8QePlxe2nfasD7r4FEGpmqo7nbURw6g,8124
|
|
8
|
+
machbaseAPI/packet.py,sha256=TLb2oKflSVuLQK03o69fxQCoglbErCjC5LBg66z5rAE,2753
|
|
9
|
+
machbaseAPI/protocol.py,sha256=hteGEXKD7iRstZT_xnpKt0hOixUEWpuCos3C005VBLU,26540
|
|
10
|
+
machbaseAPI/types.py,sha256=LJWeBj5HTTHPq9UFJDaCQqToQQvsK3Ce7iKU5R5TnDw,1481
|
|
11
|
+
machbaseAPI/sample/ConnTest.py,sha256=cQKmxXexlqOC7b4ERD59pws3EYEkEE-C_yy3VZnZp3Y,1520
|
|
12
|
+
machbaseAPI/sample/MakeData.py,sha256=7oJ4wSX0MZ399rQfabmnmKhrWWa9mw1oBgf3MvXBYI8,752
|
|
13
|
+
machbaseAPI/sample/Sample1Connect.py,sha256=HCM1LL7zSra_fpdM8O1eHsQTzQj3YDQDKdvX0MD1UM8,728
|
|
14
|
+
machbaseAPI/sample/Sample2Simple.py,sha256=IUFF0Z9-EMf3onF2_lzPnOILiazBvD1tCIng6TXPmr0,2545
|
|
15
|
+
machbaseAPI/sample/Sample3Append.py,sha256=p2dbj5bIvyDAnEM2Ef90PcMN0jyzonL9Ib3AgmYa73U,2097
|
|
16
|
+
machbaseAPI/sample/Sample4Fetch.py,sha256=0xAUCQ2OZ9KJxu7D4LybmSLKoUVQseMqyCxNnoszQy8,4009
|
|
17
|
+
machbaseAPI/sample/Sample5Append2.py,sha256=QcpKILfsHvHLZ2x8VEsu9Pf2B2bgvWAlO20kHIrv7K0,2371
|
|
18
|
+
machbaseAPI/sample/Sample5ConnectEx.py,sha256=0xF384u0EqXkVCIzT1Z2ld-SdjuD32GYRBS2rWMA8cY,1555
|
|
19
|
+
machbaseAPI/sample/__init__.py,sha256=Zu6q0k0Mqi4mN48_j7BMHCXEwTCpqdo0OXh2dnXixg0,57
|
|
20
|
+
machbaseAPI/sample/data.txt,sha256=QMHDO82-WFE_eKDk6oiBRvX7-i07RfjwOXwQkqVf73s,15653
|
|
21
|
+
machbaseapi-2.0.0.dist-info/METADATA,sha256=ot8gZOG3vOJQQqeh3bDS-gm2FPMZ2W8KDSBDZvunXB8,5293
|
|
22
|
+
machbaseapi-2.0.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
23
|
+
machbaseapi-2.0.0.dist-info/top_level.txt,sha256=-9HwUvafn-uTM9ckDWa2sxP4AZE7YNdhjVWRgOAhhH0,12
|
|
24
|
+
machbaseapi-2.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
machbaseAPI
|