nzpy-extended 0.0.1__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 (48) hide show
  1. nzpy_extended-0.0.1/LICENSE +206 -0
  2. nzpy_extended-0.0.1/MANIFEST.in +3 -0
  3. nzpy_extended-0.0.1/PKG-INFO +145 -0
  4. nzpy_extended-0.0.1/README.md +117 -0
  5. nzpy_extended-0.0.1/nzpy_extended/__init__.py +85 -0
  6. nzpy_extended-0.0.1/nzpy_extended/_version.py +460 -0
  7. nzpy_extended-0.0.1/nzpy_extended/buffer_pool.py +25 -0
  8. nzpy_extended-0.0.1/nzpy_extended/buffered_stream.py +107 -0
  9. nzpy_extended-0.0.1/nzpy_extended/c_ext.c +1168 -0
  10. nzpy_extended-0.0.1/nzpy_extended/core.py +3965 -0
  11. nzpy_extended-0.0.1/nzpy_extended/handshake.py +1148 -0
  12. nzpy_extended-0.0.1/nzpy_extended/pool.py +199 -0
  13. nzpy_extended-0.0.1/nzpy_extended.egg-info/PKG-INFO +145 -0
  14. nzpy_extended-0.0.1/nzpy_extended.egg-info/SOURCES.txt +47 -0
  15. nzpy_extended-0.0.1/nzpy_extended.egg-info/dependency_links.txt +1 -0
  16. nzpy_extended-0.0.1/nzpy_extended.egg-info/requires.txt +2 -0
  17. nzpy_extended-0.0.1/nzpy_extended.egg-info/top_level.txt +1 -0
  18. nzpy_extended-0.0.1/pyproject.toml +40 -0
  19. nzpy_extended-0.0.1/setup.cfg +12 -0
  20. nzpy_extended-0.0.1/setup.py +20 -0
  21. nzpy_extended-0.0.1/tests/test_async_ops.py +288 -0
  22. nzpy_extended-0.0.1/tests/test_basic.py +339 -0
  23. nzpy_extended-0.0.1/tests/test_benchmark.py +103 -0
  24. nzpy_extended-0.0.1/tests/test_c_python_parity_integration.py +324 -0
  25. nzpy_extended-0.0.1/tests/test_c_python_parity_unit.py +635 -0
  26. nzpy_extended-0.0.1/tests/test_connection.py +179 -0
  27. nzpy_extended-0.0.1/tests/test_dbapi.py +250 -0
  28. nzpy_extended-0.0.1/tests/test_executing_lock.py +43 -0
  29. nzpy_extended-0.0.1/tests/test_external_table.py +700 -0
  30. nzpy_extended-0.0.1/tests/test_get_schema_table.py +257 -0
  31. nzpy_extended-0.0.1/tests/test_has_rows.py +212 -0
  32. nzpy_extended-0.0.1/tests/test_invalid_sql.py +224 -0
  33. nzpy_extended-0.0.1/tests/test_multi_command.py +387 -0
  34. nzpy_extended-0.0.1/tests/test_notices.py +162 -0
  35. nzpy_extended-0.0.1/tests/test_odbc_comparison.py +284 -0
  36. nzpy_extended-0.0.1/tests/test_odbc_comparison_node.py +72 -0
  37. nzpy_extended-0.0.1/tests/test_odbc_comparison_smoke.py +176 -0
  38. nzpy_extended-0.0.1/tests/test_odbc_parity_extended.py +320 -0
  39. nzpy_extended-0.0.1/tests/test_paramstyle.py +89 -0
  40. nzpy_extended-0.0.1/tests/test_pool.py +295 -0
  41. nzpy_extended-0.0.1/tests/test_query_consistency.py +239 -0
  42. nzpy_extended-0.0.1/tests/test_smoke_basic.py +306 -0
  43. nzpy_extended-0.0.1/tests/test_stack_overflow.py +70 -0
  44. nzpy_extended-0.0.1/tests/test_timeout_async.py +208 -0
  45. nzpy_extended-0.0.1/tests/test_transactions.py +103 -0
  46. nzpy_extended-0.0.1/tests/test_type_recognition.py +406 -0
  47. nzpy_extended-0.0.1/tests/test_typeobjects.py +52 -0
  48. nzpy_extended-0.0.1/tests/test_types.py +69 -0
@@ -0,0 +1,206 @@
1
+ Copyright (c) 2025, JustyBase
2
+ Copyright (c) 2020, IBM
3
+ Copyright (c) 2007-2009, Mathieu Fenniak
4
+ All rights reserved.
5
+
6
+ Apache License
7
+ Version 2.0, January 2004
8
+ http://www.apache.org/licenses/
9
+
10
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
11
+
12
+ 1. Definitions.
13
+
14
+ "License" shall mean the terms and conditions for use, reproduction,
15
+ and distribution as defined by Sections 1 through 9 of this document.
16
+
17
+ "Licensor" shall mean the copyright owner or entity authorized by
18
+ the copyright owner that is granting the License.
19
+
20
+ "Legal Entity" shall mean the union of the acting entity and all
21
+ other entities that control, are controlled by, or are under common
22
+ control with that entity. For the purposes of this definition,
23
+ "control" means (i) the power, direct or indirect, to cause the
24
+ direction or management of such entity, whether by contract or
25
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
26
+ outstanding shares, or (iii) beneficial ownership of such entity.
27
+
28
+ "You" (or "Your") shall mean an individual or Legal Entity
29
+ exercising permissions granted by this License.
30
+
31
+ "Source" form shall mean the preferred form for making modifications,
32
+ including but not limited to software source code, documentation
33
+ source, and configuration files.
34
+
35
+ "Object" form shall mean any form resulting from mechanical
36
+ transformation or translation of a Source form, including but
37
+ not limited to compiled object code, generated documentation,
38
+ and conversions to other media types.
39
+
40
+ "Work" shall mean the work of authorship, whether in Source or
41
+ Object form, made available under the License, as indicated by a
42
+ copyright notice that is included in or attached to the work
43
+ (an example is provided in the Appendix below).
44
+
45
+ "Derivative Works" shall mean any work, whether in Source or Object
46
+ form, that is based on (or derived from) the Work and for which the
47
+ editorial revisions, annotations, elaborations, or other modifications
48
+ represent, as a whole, an original work of authorship. For the purposes
49
+ of this License, Derivative Works shall not include works that remain
50
+ separable from, or merely link (or bind by name) to the interfaces of,
51
+ the Work and Derivative Works thereof.
52
+
53
+ "Contribution" shall mean any work of authorship, including
54
+ the original version of the Work and any modifications or additions
55
+ to that Work or Derivative Works thereof, that is intentionally
56
+ submitted to Licensor for inclusion in the Work by the copyright owner
57
+ or by an individual or Legal Entity authorized to submit on behalf of
58
+ the copyright owner. For the purposes of this definition, "submitted"
59
+ means any form of electronic, verbal, or written communication sent
60
+ to the Licensor or its representatives, including but not limited to
61
+ communication on electronic mailing lists, source code control systems,
62
+ and issue tracking systems that are managed by, or on behalf of, the
63
+ Licensor for the purpose of discussing and improving the Work, but
64
+ excluding communication that is conspicuously marked or otherwise
65
+ designated in writing by the copyright owner as "Not a Contribution."
66
+
67
+ "Contributor" shall mean Licensor and any individual or Legal Entity
68
+ on behalf of whom a Contribution has been received by Licensor and
69
+ subsequently incorporated within the Work.
70
+
71
+ 2. Grant of Copyright License. Subject to the terms and conditions of
72
+ this License, each Contributor hereby grants to You a perpetual,
73
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
74
+ copyright license to reproduce, prepare Derivative Works of,
75
+ publicly display, publicly perform, sublicense, and distribute the
76
+ Work and such Derivative Works in Source or Object form.
77
+
78
+ 3. Grant of Patent License. Subject to the terms and conditions of
79
+ this License, each Contributor hereby grants to You a perpetual,
80
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
81
+ (except as stated in this section) patent license to make, have made,
82
+ use, offer to sell, sell, import, and otherwise transfer the Work,
83
+ where such license applies only to those patent claims licensable
84
+ by such Contributor that are necessarily infringed by their
85
+ Contribution(s) alone or by combination of their Contribution(s)
86
+ with the Work to which such Contribution(s) was submitted. If You
87
+ institute patent litigation against any entity (including a
88
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
89
+ or a Contribution incorporated within the Work constitutes direct
90
+ or contributory patent infringement, then any patent licenses
91
+ granted to You under this License for that Work shall terminate
92
+ as of the date such litigation is filed.
93
+
94
+ 4. Redistribution. You may reproduce and distribute copies of the
95
+ Work or Derivative Works thereof in any medium, with or without
96
+ modifications, and in Source or Object form, provided that You
97
+ meet the following conditions:
98
+
99
+ (a) You must give any other recipients of the Work or
100
+ Derivative Works a copy of this License; and
101
+
102
+ (b) You must cause any modified files to carry prominent notices
103
+ stating that You changed the files; and
104
+
105
+ (c) You must retain, in the Source form of any Derivative Works
106
+ that You distribute, all copyright, patent, trademark, and
107
+ attribution notices from the Source form of the Work,
108
+ excluding those notices that do not pertain to any part of
109
+ the Derivative Works; and
110
+
111
+ (d) If the Work includes a "NOTICE" text file as part of its
112
+ distribution, then any Derivative Works that You distribute must
113
+ include a readable copy of the attribution notices contained
114
+ within such NOTICE file, excluding those notices that do not
115
+ pertain to any part of the Derivative Works, in at least one
116
+ of the following places: within a NOTICE text file distributed
117
+ as part of the Derivative Works; within the Source form or
118
+ documentation, if provided along with the Derivative Works; or,
119
+ within a display generated by the Derivative Works, if and
120
+ wherever such third-party notices normally appear. The contents
121
+ of the NOTICE file are for informational purposes only and
122
+ do not modify the License. You may add Your own attribution
123
+ notices within Derivative Works that You distribute, alongside
124
+ or as an addendum to the NOTICE text from the Work, provided
125
+ that such additional attribution notices cannot be construed
126
+ as modifying the License.
127
+
128
+ You may add Your own copyright statement to Your modifications and
129
+ may provide additional or different license terms and conditions
130
+ for use, reproduction, or distribution of Your modifications, or
131
+ for any such Derivative Works as a whole, provided Your use,
132
+ reproduction, and distribution of the Work otherwise complies with
133
+ the conditions stated in this License.
134
+
135
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
136
+ any Contribution intentionally submitted for inclusion in the Work
137
+ by You to the Licensor shall be under the terms and conditions of
138
+ this License, without any additional terms or conditions.
139
+ Notwithstanding the above, nothing herein shall supersede or modify
140
+ the terms of any separate license agreement you may have executed
141
+ with Licensor regarding such Contributions.
142
+
143
+ 6. Trademarks. This License does not grant permission to use the trade
144
+ names, trademarks, service marks, or product names of the Licensor,
145
+ except as required for reasonable and customary use in describing the
146
+ origin of the Work and reproducing the content of the NOTICE file.
147
+
148
+ 7. Disclaimer of Warranty. Unless required by applicable law or
149
+ agreed to in writing, Licensor provides the Work (and each
150
+ Contributor provides its Contributions) on an "AS IS" BASIS,
151
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
152
+ implied, including, without limitation, any warranties or conditions
153
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
154
+ PARTICULAR PURPOSE. You are solely responsible for determining the
155
+ appropriateness of using or redistributing the Work and assume any
156
+ risks associated with Your exercise of permissions under this License.
157
+
158
+ 8. Limitation of Liability. In no event and under no legal theory,
159
+ whether in tort (including negligence), contract, or otherwise,
160
+ unless required by applicable law (such as deliberate and grossly
161
+ negligent acts) or agreed to in writing, shall any Contributor be
162
+ liable to You for damages, including any direct, indirect, special,
163
+ incidental, or consequential damages of any character arising as a
164
+ result of this License or out of the use or inability to use the
165
+ Work (including but not limited to damages for loss of goodwill,
166
+ work stoppage, computer failure or malfunction, or any and all
167
+ other commercial damages or losses), even if such Contributor
168
+ has been advised of the possibility of such damages.
169
+
170
+ 9. Accepting Warranty or Additional Liability. While redistributing
171
+ the Work or Derivative Works thereof, You may choose to offer,
172
+ and charge a fee for, acceptance of support, warranty, indemnity,
173
+ or other liability obligations and/or rights consistent with this
174
+ License. However, in accepting such obligations, You may act only
175
+ on Your own behalf and on Your sole responsibility, not on behalf
176
+ of any other Contributor, and only if You agree to indemnify,
177
+ defend, and hold each Contributor harmless for any liability
178
+ incurred by, or claims asserted against, such Contributor by reason
179
+ of your accepting any such warranty or additional liability.
180
+
181
+ END OF TERMS AND CONDITIONS
182
+
183
+ APPENDIX: How to apply the Apache License to your work.
184
+
185
+ To apply the Apache License to your work, attach the following
186
+ boilerplate notice, with the fields enclosed by brackets "{}"
187
+ replaced with your own identifying information. (Don't include
188
+ the brackets!) The text should be enclosed in the appropriate
189
+ comment syntax for the file format. We also recommend that a
190
+ file or class name and description of purpose be included on the
191
+ same "printed page" as the copyright notice for easier
192
+ identification within third-party archives.
193
+
194
+ Copyright {yyyy} {name of copyright owner}
195
+
196
+ Licensed under the Apache License, Version 2.0 (the "License");
197
+ you may not use this file except in compliance with the License.
198
+ You may obtain a copy of the License at
199
+
200
+ http://www.apache.org/licenses/LICENSE-2.0
201
+
202
+ Unless required by applicable law or agreed to in writing, software
203
+ distributed under the License is distributed on an "AS IS" BASIS,
204
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
205
+ See the License for the specific language governing permissions and
206
+ limitations under the License.
@@ -0,0 +1,3 @@
1
+ include LICENSE
2
+ include README.md
3
+ include nzpy_extended/c_ext.c
@@ -0,0 +1,145 @@
1
+ Metadata-Version: 2.4
2
+ Name: nzpy_extended
3
+ Version: 0.0.1
4
+ Summary: IBM Netezza python driver - extended fork
5
+ Author: krzysztof-d
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Documentation, https://github.com/JustyBase/nzpy_extended/wiki
8
+ Project-URL: Source, https://github.com/JustyBase/nzpy_extended
9
+ Project-URL: Tracker, https://github.com/JustyBase/nzpy_extended/issues
10
+ Keywords: Netezza,nps,db-api,dbapi,driver,async,ibm-netezza,postgresql,extended
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Programming Language :: Python :: Implementation :: CPython
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Topic :: Database :: Front-Ends
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.12
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: scramp>=1.4.5
26
+ Requires-Dist: looseversion>=1.3.0
27
+ Dynamic: license-file
28
+
29
+ # nzpy_extended: High-performance IBM Netezza driver for Python
30
+
31
+ **nzpy_extended** is a hard fork of [IBM nzpy](https://github.com/IBM/nzpy) — enriched with new features, major performance improvements via a C extension, and expanded platform support.
32
+
33
+ ## Key differences from upstream nzpy
34
+
35
+ | Feature | nzpy (IBM) | nzpy_extended |
36
+ |---|---|---|
37
+ | Row parsing performance | ~13 000 rows/s (pure Python) | ~50 000 rows/s (optimized Python) → ~200 000 rows/s (+ C ext, exceeds ODBC ~160 k) |
38
+ | Supported Python | 3.5+ | **3.12, 3.13, 3.14** |
39
+ | Platform wheels | ❌ None | ✅ Linux x64, macOS ARM, Windows x64 (pre-built) |
40
+ | Async support | ❌ | ✅ Fully async API |
41
+
42
+ A large portion of the speedup comes from avoiding unnecessary object allocations in pure Python (~13 k → ~50 k rows/s). When the C extension is available (`_HAVE_C_EXT = True`), parsing of integers, floats, decimals, dates, times, timestamps, booleans, and strings all happen in native C — avoiding Python object allocations per field and `struct.unpack` overhead — boosting throughput to ~200 k rows/s.
43
+
44
+ If the compiled extension is not available (unsupported platform or Python version), the driver **gracefully falls back** to pure Python with identical semantics.
45
+
46
+ ## Installation
47
+
48
+ ```shell
49
+ pip install nzpy_extended
50
+ ```
51
+
52
+ Pre-built wheels are provided for:
53
+
54
+ | Platform | Architecture | Python |
55
+ |---|---|---|
56
+ | Linux | x86_64 (manylinux) | 3.12 / 3.13 / 3.14 |
57
+ | macOS | ARM64 (Apple Silicon) | 3.12 / 3.13 / 3.14 |
58
+ | Windows | x86_64 | 3.12 / 3.13 / 3.14 |
59
+
60
+ For other platforms or Python versions, `pip install` will compile the C extension from source (requires a C compiler: GCC, Clang, or MSVC). On systems without a compiler the install will fail — use a supported platform or version.
61
+
62
+ ## Quick start
63
+
64
+ ```python
65
+ import nzpy_extended as nzpy
66
+
67
+ conn = nzpy.connect(
68
+ user="admin", password="password",
69
+ host="localhost", port=5480, database="db1",
70
+ securityLevel=1,
71
+ )
72
+
73
+ with conn.cursor() as cursor:
74
+ cursor.execute("CREATE TABLE IF NOT EXISTS test (id INT, name VARCHAR(50))")
75
+ cursor.execute("INSERT INTO test VALUES (?, ?)", (1, "Alice"))
76
+ cursor.execute("SELECT * FROM test")
77
+ rows = cursor.fetchall()
78
+ for row in rows:
79
+ print(row)
80
+ ```
81
+
82
+ ## Requirements
83
+
84
+ - Python ≥ 3.12
85
+ - CPython (PyPy not supported for C extension, pure-Python fallback only)
86
+
87
+ ## Documentation
88
+
89
+ - [GitHub Wiki](https://github.com/JustyBase/nzpy_extended/wiki)
90
+ - [Issue tracker](https://github.com/JustyBase/nzpy_extended/issues)
91
+
92
+ ## Testing
93
+
94
+ ### Running the test suite
95
+
96
+ Tests require a running Netezza instance. Set the connection environment variables:
97
+
98
+ ```shell
99
+ export NZ_DEV_HOST=your_netezza_host
100
+ export NZ_DEV_PORT=5480
101
+ export NZ_DEV_DB=JUST_DATA
102
+ export NZ_DEV_USER=admin
103
+ export NZ_DEV_PASSWORD=password
104
+ ```
105
+
106
+ Run all tests:
107
+ ```shell
108
+ pytest tests/ -v
109
+ ```
110
+
111
+ ### C Extension / Pure Python parity
112
+
113
+ The C extension and pure-Python fallback must produce identical results for all data types. Parity tests verify this in two ways:
114
+
115
+ **Unit tests** (`tests/test_c_python_parity_unit.py`) — compare individual C parser functions against Python reference implementations byte-by-byte. No database required.
116
+
117
+ ```shell
118
+ pytest tests/test_c_python_parity_unit.py -v
119
+ ```
120
+
121
+ **Integration tests** (`tests/test_c_python_parity_integration.py`) — run real SQL queries through both code paths and verify results match. Requires a database.
122
+
123
+ ```shell
124
+ pytest tests/test_c_python_parity_integration.py -v
125
+ ```
126
+
127
+ **Verification script** — runs both test suites in C-extension and pure-Python modes side-by-side:
128
+
129
+ ```shell
130
+ python tools/verify_c_python_parity.py
131
+ ```
132
+
133
+ **Disabling C extension at runtime:**
134
+
135
+ Set the environment variable `NZPY_EXTENDED_NO_CEXT=1` to force pure-Python mode even when the compiled extension is available. Useful for debugging or verifying fallback correctness.
136
+
137
+ ```shell
138
+ NZPY_EXTENDED_NO_CEXT=1 pip install nzpy_extended
139
+ # or at runtime:
140
+ NZPY_EXTENDED_NO_CEXT=1 python -c "import nzpy_extended.core; print(nzpy_extended.core._HAVE_C_EXT)" # False
141
+ ```
142
+
143
+ ## License
144
+
145
+ Apache License 2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,117 @@
1
+ # nzpy_extended: High-performance IBM Netezza driver for Python
2
+
3
+ **nzpy_extended** is a hard fork of [IBM nzpy](https://github.com/IBM/nzpy) — enriched with new features, major performance improvements via a C extension, and expanded platform support.
4
+
5
+ ## Key differences from upstream nzpy
6
+
7
+ | Feature | nzpy (IBM) | nzpy_extended |
8
+ |---|---|---|
9
+ | Row parsing performance | ~13 000 rows/s (pure Python) | ~50 000 rows/s (optimized Python) → ~200 000 rows/s (+ C ext, exceeds ODBC ~160 k) |
10
+ | Supported Python | 3.5+ | **3.12, 3.13, 3.14** |
11
+ | Platform wheels | ❌ None | ✅ Linux x64, macOS ARM, Windows x64 (pre-built) |
12
+ | Async support | ❌ | ✅ Fully async API |
13
+
14
+ A large portion of the speedup comes from avoiding unnecessary object allocations in pure Python (~13 k → ~50 k rows/s). When the C extension is available (`_HAVE_C_EXT = True`), parsing of integers, floats, decimals, dates, times, timestamps, booleans, and strings all happen in native C — avoiding Python object allocations per field and `struct.unpack` overhead — boosting throughput to ~200 k rows/s.
15
+
16
+ If the compiled extension is not available (unsupported platform or Python version), the driver **gracefully falls back** to pure Python with identical semantics.
17
+
18
+ ## Installation
19
+
20
+ ```shell
21
+ pip install nzpy_extended
22
+ ```
23
+
24
+ Pre-built wheels are provided for:
25
+
26
+ | Platform | Architecture | Python |
27
+ |---|---|---|
28
+ | Linux | x86_64 (manylinux) | 3.12 / 3.13 / 3.14 |
29
+ | macOS | ARM64 (Apple Silicon) | 3.12 / 3.13 / 3.14 |
30
+ | Windows | x86_64 | 3.12 / 3.13 / 3.14 |
31
+
32
+ For other platforms or Python versions, `pip install` will compile the C extension from source (requires a C compiler: GCC, Clang, or MSVC). On systems without a compiler the install will fail — use a supported platform or version.
33
+
34
+ ## Quick start
35
+
36
+ ```python
37
+ import nzpy_extended as nzpy
38
+
39
+ conn = nzpy.connect(
40
+ user="admin", password="password",
41
+ host="localhost", port=5480, database="db1",
42
+ securityLevel=1,
43
+ )
44
+
45
+ with conn.cursor() as cursor:
46
+ cursor.execute("CREATE TABLE IF NOT EXISTS test (id INT, name VARCHAR(50))")
47
+ cursor.execute("INSERT INTO test VALUES (?, ?)", (1, "Alice"))
48
+ cursor.execute("SELECT * FROM test")
49
+ rows = cursor.fetchall()
50
+ for row in rows:
51
+ print(row)
52
+ ```
53
+
54
+ ## Requirements
55
+
56
+ - Python ≥ 3.12
57
+ - CPython (PyPy not supported for C extension, pure-Python fallback only)
58
+
59
+ ## Documentation
60
+
61
+ - [GitHub Wiki](https://github.com/JustyBase/nzpy_extended/wiki)
62
+ - [Issue tracker](https://github.com/JustyBase/nzpy_extended/issues)
63
+
64
+ ## Testing
65
+
66
+ ### Running the test suite
67
+
68
+ Tests require a running Netezza instance. Set the connection environment variables:
69
+
70
+ ```shell
71
+ export NZ_DEV_HOST=your_netezza_host
72
+ export NZ_DEV_PORT=5480
73
+ export NZ_DEV_DB=JUST_DATA
74
+ export NZ_DEV_USER=admin
75
+ export NZ_DEV_PASSWORD=password
76
+ ```
77
+
78
+ Run all tests:
79
+ ```shell
80
+ pytest tests/ -v
81
+ ```
82
+
83
+ ### C Extension / Pure Python parity
84
+
85
+ The C extension and pure-Python fallback must produce identical results for all data types. Parity tests verify this in two ways:
86
+
87
+ **Unit tests** (`tests/test_c_python_parity_unit.py`) — compare individual C parser functions against Python reference implementations byte-by-byte. No database required.
88
+
89
+ ```shell
90
+ pytest tests/test_c_python_parity_unit.py -v
91
+ ```
92
+
93
+ **Integration tests** (`tests/test_c_python_parity_integration.py`) — run real SQL queries through both code paths and verify results match. Requires a database.
94
+
95
+ ```shell
96
+ pytest tests/test_c_python_parity_integration.py -v
97
+ ```
98
+
99
+ **Verification script** — runs both test suites in C-extension and pure-Python modes side-by-side:
100
+
101
+ ```shell
102
+ python tools/verify_c_python_parity.py
103
+ ```
104
+
105
+ **Disabling C extension at runtime:**
106
+
107
+ Set the environment variable `NZPY_EXTENDED_NO_CEXT=1` to force pure-Python mode even when the compiled extension is available. Useful for debugging or verifying fallback correctness.
108
+
109
+ ```shell
110
+ NZPY_EXTENDED_NO_CEXT=1 pip install nzpy_extended
111
+ # or at runtime:
112
+ NZPY_EXTENDED_NO_CEXT=1 python -c "import nzpy_extended.core; print(nzpy_extended.core._HAVE_C_EXT)" # False
113
+ ```
114
+
115
+ ## License
116
+
117
+ Apache License 2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,85 @@
1
+ from nzpy_extended.core import (ArrayContentNotHomogenousError,
2
+ ArrayContentNotSupportedError,
3
+ ArrayDimensionsNotConsistentError, BINARY,
4
+ Binary, Connection, Cursor, DataError,
5
+ DatabaseError, Date, DateFromTicks, Error,
6
+ IntegrityError, InterfaceError, InternalError,
7
+ Interval, LogOptions, NotSupportedError,
8
+ OperationalError, PGEnum, PGJson, PGJsonb,
9
+ PGText, PGTsvector, PGVarchar, ProgrammingError,
10
+ Time, TimeFromTicks, Timestamp, TimestampFromTicks,
11
+ Warning)
12
+ from nzpy_extended.pool import NzPool
13
+
14
+ from ._version import get_versions
15
+
16
+ __version__ = get_versions()['version']
17
+ del get_versions
18
+
19
+ __author__ = "Mathieu Fenniak"
20
+
21
+ async def connect(user, host='localhost', unix_sock=None, port=5432, database=None,
22
+ password=None, ssl=None, securityLevel=0, timeout=None,
23
+ application_name=None, max_prepared_statements=1000,
24
+ datestyle='ISO', logLevel=0, tcp_keepalive=True,
25
+ char_varchar_encoding='latin', logOptions=LogOptions.Inherit,
26
+ pgOptions=None):
27
+
28
+ conn = Connection()
29
+ await conn._connect(user, host, unix_sock, port, database, password, ssl,
30
+ securityLevel, timeout, application_name,
31
+ max_prepared_statements, datestyle, logLevel,
32
+ tcp_keepalive, char_varchar_encoding,
33
+ logOptions, pgOptions)
34
+ return conn
35
+
36
+
37
+ apilevel = "2.0"
38
+ """The DBAPI level supported, currently "2.0".
39
+ This property is part of the `DBAPI 2.0 specification
40
+ <http://www.python.org/dev/peps/pep-0249/>`_.
41
+ """
42
+
43
+ threadsafety = 1
44
+ """Integer constant stating the level of thread safety the DBAPI interface
45
+ supports. This DBAPI module supports sharing of the module only. Connections
46
+ and cursors my not be shared between threads. This gives nzpy_extended a threadsafety
47
+ value of 1.
48
+ This property is part of the `DBAPI 2.0 specification
49
+ <http://www.python.org/dev/peps/pep-0249/>`_.
50
+ """
51
+
52
+ paramstyle = 'qmark'
53
+
54
+ max_prepared_statements = 1000
55
+
56
+ # I have no idea what this would be used for by a client app. Should it be
57
+ # TEXT, VARCHAR, CHAR? It will only compare against row_description's
58
+ # type_code if it is this one type. It is the varchar type oid for now, this
59
+ # appears to match expectations in the DB API 2.0 compliance test suite.
60
+
61
+ STRING = 1043
62
+ """String type oid."""
63
+
64
+
65
+ NUMBER = 1700
66
+ """Numeric type oid"""
67
+
68
+ DATETIME = 1114
69
+ """Timestamp type oid"""
70
+
71
+ ROWID = 26
72
+ """ROWID type oid"""
73
+
74
+ __all__ = [
75
+ Warning, DataError, DatabaseError, connect, InterfaceError,
76
+ ProgrammingError, Error, OperationalError, IntegrityError, InternalError,
77
+ NotSupportedError, ArrayContentNotHomogenousError,
78
+ ArrayDimensionsNotConsistentError, ArrayContentNotSupportedError,
79
+ Connection, Cursor, Binary, Date, DateFromTicks, Time, TimeFromTicks,
80
+ Timestamp, TimestampFromTicks, BINARY, Interval, PGEnum, PGJson, PGJsonb,
81
+ PGTsvector, PGText, PGVarchar]
82
+
83
+ """Version string for nzpy_extended.
84
+ .. versionadded:: 1.9.11
85
+ """