oracle-driver 1.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.
@@ -0,0 +1,169 @@
1
+ Metadata-Version: 2.4
2
+ Name: oracle-driver
3
+ Version: 1.0.0
4
+ Summary: Native pure-Python Oracle driver — a clean-room port of the go-ora v2 TTC/Net8 wire protocol. No Oracle client, no CGO.
5
+ Author-email: gjb711 <gjb711@qq.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/gjb711/oracle-driver
8
+ Project-URL: Repository, https://github.com/gjb711/oracle-driver
9
+ Project-URL: Documentation, https://github.com/gjb711/oracle-driver#readme
10
+ Keywords: oracle,driver,database,ttc,net8,go-ora,pure-python
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Database
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.8
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Dynamic: license-file
26
+
27
+ # pyora — a native pure-Python Oracle driver (port of go-ora v2)
28
+
29
+ `pyora` is a from-scratch, pure-Python reimplementation of the
30
+ [`github.com/sijms/go-ora/v2`](https://github.com/sijms/go-ora/v2) Oracle driver.
31
+ Like go-ora, it is **fully self-contained**: it speaks the Oracle TTC / Net8
32
+ wire protocol directly over TCP and needs **no Oracle Instant Client, no CGO
33
+ counterpart, and no DLL**, so the resulting package is pure Python and portable
34
+ to any platform with CPython.
35
+
36
+ > Scope note: this is the **core working driver** — a faithful port of the
37
+ > connect + O5LOGON authentication + query/execute/fetch + core data-type path
38
+ > that most applications need. The more exotic go-ora subsystems (TLS/Kerberos
39
+ > advanced network services, UDT/XML collection support, vector, bulk copy,
40
+ > streaming CLOB/BLOB fetch) are intentionally out of scope here and documented
41
+ > under *Limitations*.
42
+
43
+ ## Quick start
44
+
45
+ ```python
46
+ import pyora
47
+
48
+ conn = pyora.connect("oracle://scott:tiger@localhost:1521/XEPDB1")
49
+ cur = conn.cursor()
50
+ cur.execute("SELECT empno, ename, sal FROM emp WHERE deptno = :1", (10,))
51
+ for row in cur:
52
+ print(row)
53
+ cur.close()
54
+ conn.close()
55
+ ```
56
+
57
+ The connection string follows go-ora's format:
58
+
59
+ ```
60
+ oracle://user:password@host:port/service_name?OPTION=value
61
+ ```
62
+
63
+ Supported options (subset of go-ora's): `SID`, `SERVICE NAME`, `INSTANCE NAME`,
64
+ `CHARSET` (e.g. `AL32UTF8`), `CONNSTR` (a full TNS descriptor),
65
+ `SERVER=`*host:port[,host:port]*, `AUTH TYPE` (`OS`/`NORMAL`), `DBA PRIVILEGE`
66
+ (`SYSDBA`/`SYSOPER`/…), `CONNECT TIMEOUT`, `TIMEOUT`, `TRACE FILE DIR`, `LOB FETCH`.
67
+
68
+ The package also exposes the go-ora-style low-level API:
69
+
70
+ ```python
71
+ from pyora.connection import Connection
72
+ conn = Connection("oracle://scott:tiger@localhost:1521/XEPDB1")
73
+ conn.connect()
74
+ rs = conn.query("SELECT name FROM t WHERE id = :1", (42,))
75
+ print(rs.columns()) # [(name, oci_type), ...]
76
+ for row in rs.rows():
77
+ print(row)
78
+ conn.close()
79
+ ```
80
+
81
+ ## Architecture (mirrors go-ora v2)
82
+
83
+ ```
84
+ pyora/
85
+ __init__.py high-level connect() + DB-API 2.0 style cursor/conn
86
+ configurations.py DSN parsing + TNS connect descriptor generation
87
+ (go-ora configurations/connect_config.go)
88
+ connection.py Connection: session, protocol/data-type negotiation,
89
+ O5LOGON auth, version retrieval, query/exec
90
+ (go-ora connection.go)
91
+ auth_object.py O5LOGON / O5AUTH: DES/AES session-key exchange,
92
+ SHA1/PBKDF2 verifiers, speedy-key
93
+ (go-ora auth_object.go)
94
+ tcp_protocol_nego.py TCP protocol negotiation (go-ora tcp_protocol_nego.go)
95
+ data_type_nego.py DTY (data type) negotiation, TZ handshake
96
+ (go-ora data_type_nego.go)
97
+ command.py statement parsing + query/execute/fetch flow
98
+ (go-ora command.go)
99
+ data_set.py Column / DataSet result model (go-ora data_set.go)
100
+ parameter_encode.py bind-parameter wire encoding
101
+ (go-ora parameter_encode.go)
102
+ oracle_type.py TNS/OCI type constants (go-ora parameter.go)
103
+ db_version.py database version retrieval (go-ora db_version.go)
104
+ converters/
105
+ number.py Oracle NUMBER binary <-> int/float/Decimal
106
+ (go-ora number.go / converters/oracle_number.go)
107
+ type_conversion.py column metadata + row value decoding
108
+ (go-ora converters/type_conversion.go, parameter.go)
109
+ strings.py server charset id -> Python codec
110
+ (go-ora converters/string_conversion.go)
111
+ network/
112
+ session.py TTC byte (de)serialization + packet framing
113
+ (go-ora network/session.go)
114
+ packets.py packet types + header layout (go-ora packets.go)
115
+ connect/accept/refuse/redirect/marker/data_packet.py
116
+ session_ctx.py, summary_object.py, oracle_error.py
117
+ ```
118
+
119
+ ## Verification
120
+
121
+ The port ships a consolidated byte-level verification suite that runs without a
122
+ live Oracle:
123
+
124
+ ```
125
+ python -m tests.test_core # 29 checks: NUMBER, config, CLR, packets, strings, binds
126
+ ```
127
+
128
+ Run on Windows with `PYTHONIOENCODING=utf-8` if your console is a non-UTF-8
129
+ codepage.
130
+
131
+ A live end-to-end check against a real Oracle instance (`CONNECTED`, `SELECT 1`,
132
+ and a multi-row/multi-column data query over VARCHAR2/DATE/NUMBER with NULL
133
+ handling) passes on Oracle 11g (192.168.30.182:11521, SID `orcl`).
134
+
135
+ ## Data-type coverage
136
+
137
+ | Oracle type | Python value |
138
+ |--------------------------|--------------|
139
+ | NUMBER / FLOAT / BINTEGER| `int`, `float`, `decimal.Decimal` |
140
+ | VARCHAR2 / CHAR / LONG | `str` (charset-aware) |
141
+ | RAW / LONG RAW | `bytes` |
142
+ | DATE | `datetime.datetime` (year §100-format, BC→year≤0) |
143
+ | TIMESTAMP / TIMESTAMP TZ / LTZ | `datetime.datetime` (µs) |
144
+ | ROWID / UROWID | `str` |
145
+ | BOOLEAN | `bool` |
146
+ | NULL | `None` |
147
+ | CLOB / BLOB | inline bytes/str (locator returned) |
148
+
149
+ ## Limitations (deliberately out of the core scope)
150
+
151
+ - **Advanced network services** (TLS, Kerberos, AES network encryption beyond
152
+ the O5LOGON session-key exchange) are not implemented. Plain TCP to a server
153
+ that does not *require* advanced services works; it will not interoperate
154
+ with a database configured to mandate encryption/NTS auth.
155
+ - **Bind parameters in `Command.writePars`** and **LOBFETCH / subsequent row
156
+ batches** are stubbed (`NotImplementedError` / `fetch_more` TODO) — the
157
+ implemented path covers non-parameterized SQL and the inline-first-batch
158
+ fetch. The `execute`/`query` DB-API helpers currently bind positional params
159
+ for the common in-memory case.
160
+ - UDT/collection/ref-cursor, vector, and bulk-copy paths are not ported.
161
+ - Existing validation is byte-level (wire-format vectors + round-trips); a live
162
+ Oracle is needed to confirm the full connect handshake against a real server.
163
+
164
+ ## License
165
+
166
+ This is an independent clean-room-style port of the go-ora v2 wire protocol.
167
+ go-ora is MIT-licensed; please retain the upstream attribution for the protocol
168
+ work it represents. See `LICENSE` of the upstream
169
+ [`sijms/go-ora`](https://github.com/sijms/go-ora) repository.
@@ -0,0 +1,34 @@
1
+ oracle_driver-1.0.0.dist-info/licenses/LICENSE,sha256=Sn71ppw8bap5dI2wtGuzVQaLbawPHXwiylhVCsz9ce4,1349
2
+ pyora/__init__.py,sha256=G0bgJW_rWqiKowyrnhRDQeB64qG-cULApl-1ClHHNzY,5571
3
+ pyora/advanced_nego.py,sha256=HKPEKiNAbcgwIezEM9x5_OidFJ2uGIgPoR_B-sm3gTw,15149
4
+ pyora/auth_object.py,sha256=ICEuVhJZK4GBfb4QZUiSwu9OCck4h9WSQpqAaFhpBfA,14238
5
+ pyora/command.py,sha256=3JcwdYxAH7QnjxPDXSmfKjvtMMDwzzfkF5wqSPsUJQg,26261
6
+ pyora/configurations.py,sha256=U7GEoCQXfbZ5Re88LqcoAxANkobVotVet2g-WmwuZJU,16114
7
+ pyora/connection.py,sha256=vwDPkYSPti4KYLQQP2CwHMJzQnFuiuJevy_EFPusO5k,14945
8
+ pyora/data_set.py,sha256=w-tq405T6y4LEuUR4TtqTKkP6NNMhWNzC7GD9i_tX7A,4236
9
+ pyora/data_type_nego.py,sha256=T54IutDxdSa63xpBgktxVsqY6pKUkuc_poa8_h-Tzso,15294
10
+ pyora/db_version.py,sha256=RiUBHPOj6P8dSwgU7sMEITlOgsEBmLftOQVa06Nw_b4,1400
11
+ pyora/oracle_type.py,sha256=dggDgNyd63Z2HIcLesGHcKl8nuFE4U3ZSvKWViENAK8,4309
12
+ pyora/parameter_encode.py,sha256=TZGRUYTeDQqbWlBm20A9kBUXmXFk97DtSLVi21RIdhI,4480
13
+ pyora/tcp_protocol_nego.py,sha256=_Z_DnN4s3gEDvlfgvOUy0ugG7-7o8nv_J1Habo0B1xs,2601
14
+ pyora/converters/__init__.py,sha256=zidpHrqrwx1WDdwcALsc6pghOpydxo1e08eLZ1ds8M8,370
15
+ pyora/converters/number.py,sha256=EOXuHRYENOzuHiTBaxzoNL8Vgi3YOrthx6DPhHZIgIM,9570
16
+ pyora/converters/strings.py,sha256=JotwirJvQGWNzJ8qjhHCQsAYnnH0Ol1N9RC6EU5rzFE,3697
17
+ pyora/converters/type_conversion.py,sha256=y0jSo25S7vf-JN5UhPbi6x8GBbexXhgwWRKc3ZZi79M,11251
18
+ pyora/converters/types_const.py,sha256=JKKpXoVu7qE9xoeucgTi_0dYmx_TgIMJkfMnPhcn0yE,1885
19
+ pyora/network/__init__.py,sha256=vw6S3DsEr2-2uJNGbqiHrVBMdBCvi46hRoiNyFxmSZM,72
20
+ pyora/network/accept_packet.py,sha256=GYSPdJp-cv778_0AzyjF3XzghBUh3xTyE-1l9ujZn8E,2028
21
+ pyora/network/connect_packet.py,sha256=3KPuYH6XEIc7Lennmo5DEnpay6NdaAzkdmy4IhVj_ME,1839
22
+ pyora/network/data_packet.py,sha256=1tF7tuFBII3L5HZIBmRTWmshKEV7oVJA3XAXHsNe__Y,2491
23
+ pyora/network/marker_packet.py,sha256=HLdIIpPx91iwcoenk5Q7-d7fenEZ6VN0D69e5utzLC8,1370
24
+ pyora/network/oracle_error.py,sha256=_qgDA_xqERkzDh6FZ_NKooybrB4-zhJ8Hz0FHBiMa78,2556
25
+ pyora/network/packets.py,sha256=GCYo2Hx2u4cJGw2jlQFqGKU1lOQii7ZphcM4d2VEkDY,1203
26
+ pyora/network/refuse_packet.py,sha256=ifsTDs5N8TDrNLJcU80EfiZJqgj2iszt-Ss55B4gBXU,2366
27
+ pyora/network/session.py,sha256=J3s-ROh_mhLyO1T_6kMBC6hvOF4ukNZ5E8j44w884eo,18788
28
+ pyora/network/session_ctx.py,sha256=2D615_0h8hWfxrq2WZGNqeekAPpf6gE3QB0o4Y00H24,1739
29
+ pyora/network/summary_object.py,sha256=dxrCMkBaVy0p8XVbiYF0rbt61PazFYGpJ3WQg5t6DEU,4691
30
+ pyora/types/__init__.py,sha256=l2Puhuib6k1C0m_6WcCVJfCg0F_JykPh-hQL_T9P2og,81
31
+ oracle_driver-1.0.0.dist-info/METADATA,sha256=KhokvinB-dhIsgbWrBm3ssyjnUBsRkDeyG4gzdyg1rE,7611
32
+ oracle_driver-1.0.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
33
+ oracle_driver-1.0.0.dist-info/top_level.txt,sha256=Int-RV3L1cHfA5aR5oAUyJf73-xUB03A6IE4LQZbhLE,6
34
+ oracle_driver-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,26 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 gjb711
4
+
5
+ This is an independent, clean-room port of the go-ora v2 wire protocol.
6
+ Upstream go-ora (github.com/sijms/go-ora) is MIT-licensed by Mahmoud Sijelmassi
7
+ ("sijms"); see https://github.com/sijms/go-ora for the upstream license and
8
+ attribution for the protocol work this port builds upon.
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ pyora
pyora/__init__.py ADDED
@@ -0,0 +1,191 @@
1
+ """
2
+ pyora — a native, pure-Python Oracle client driver ported from
3
+ github.com/sijms/go-ora/v2.
4
+
5
+ No Oracle client is required. The driver speaks the TTC/Net8 wire protocol
6
+ directly over TCP, mirroring go-ora v2's architecture:
7
+ pyora.network low-level TTC serialization, packets, session
8
+ pyora.configurations connection-string parsing / connect descriptor
9
+ pyora.auth_object O5LOGON authentication
10
+ pyora.connection high-level Connection (connect / query / exec)
11
+ pyora.converters Oracle data type <-> Python conversions
12
+ pyora.command statement parsing, query/execute/fetch flow
13
+
14
+ Basic use:
15
+ import pyora
16
+ conn = pyora.connect("oracle://scott:tiger@localhost:1521/XEPDB1")
17
+ cur = conn.cursor()
18
+ cur.execute("SELECT * FROM emp")
19
+ for row in cur:
20
+ print(row)
21
+ """
22
+
23
+ from .configurations import parse_config, ConnectionConfig
24
+ from .network.oracle_error import OracleError
25
+ from .connection import Connection
26
+
27
+ __version__ = "0.1.0"
28
+
29
+ __all__ = ["connect", "Connection", "OracleError", "parse_config", "Cursor", "ConnectionWrapper"]
30
+
31
+
32
+ class Cursor:
33
+ """A minimal DB-API 2.0 style cursor over a Connection."""
34
+
35
+ def __init__(self, connection):
36
+ self._connection = connection
37
+ self._result = None
38
+ self._rows = None
39
+ self._row_index = 0
40
+ self.description = None
41
+ self.rowcount = -1
42
+
43
+ def execute(self, query, args=None):
44
+ args = args if args is not None else ()
45
+ if isinstance(args, dict):
46
+ # dict params are not supported by this simple layer; require tuple/list
47
+ args = tuple(args.values()) if args else ()
48
+ sql = query.strip().rstrip(";")
49
+ if _is_query(sql):
50
+ rs = self._connection.query(query, tuple(args) if args else ())
51
+ self._rows = rs.rows()
52
+ self.description = _build_description(rs.columns())
53
+ self.rowcount = len(self._rows) if self._rows else -1
54
+ else:
55
+ rc = self._connection.exec(query, (args,)).rowcount
56
+ self._rows = None
57
+ self.rowcount = rc
58
+ self.description = None
59
+ self._row_index = 0
60
+ return self
61
+
62
+ def executemany(self, query, seq_of_params):
63
+ total = 0
64
+ for params in seq_of_params:
65
+ self.execute(query, params)
66
+ total += (self.rowcount if self.rowcount and self.rowcount > 0 else 1)
67
+ self.rowcount = total
68
+ return self
69
+
70
+ def fetchone(self):
71
+ if self._rows is None or self._row_index >= len(self._rows):
72
+ return None
73
+ row = self._rows[self._row_index]
74
+ self._row_index += 1
75
+ return tuple(row)
76
+
77
+ def fetchmany(self, size=None):
78
+ if size is None:
79
+ size = 1
80
+ out = []
81
+ for _ in range(size):
82
+ row = self.fetchone()
83
+ if row is None:
84
+ break
85
+ out.append(row)
86
+ return out
87
+
88
+ def fetchall(self):
89
+ out = []
90
+ while True:
91
+ row = self.fetchone()
92
+ if row is None:
93
+ break
94
+ out.append(row)
95
+ return out
96
+
97
+ def __iter__(self):
98
+ return self
99
+
100
+ def __next__(self):
101
+ row = self.fetchone()
102
+ if row is None:
103
+ raise StopIteration
104
+ return row
105
+
106
+ def close(self):
107
+ self._rows = None
108
+
109
+ def setinputsizes(self, *args):
110
+ pass
111
+
112
+ def setoutputsize(self, size, column=None):
113
+ pass
114
+
115
+
116
+ def _is_query(sql):
117
+ head = sql.lstrip().upper()[:6]
118
+ return head.startswith("SELECT") or head.startswith("WITH") or head.startswith("CALL") \
119
+ or head.startswith("EXPLAIN")
120
+
121
+
122
+ def _build_description(columns):
123
+ if not columns:
124
+ return None
125
+ desc = []
126
+ for col in columns:
127
+ name = col[0] if isinstance(col, (tuple, list)) else getattr(col, "name", "")
128
+ oci = col[1] if isinstance(col, (tuple, list)) and len(col) > 1 else getattr(col, "oci_type", None)
129
+ desc.append((name, oci, None, None, None, None, None))
130
+ return desc
131
+
132
+
133
+ class ConnectionWrapper:
134
+ """DB-API style wrapper exposing cursor(), commit(), rollback(), close()."""
135
+
136
+ def __init__(self, connection):
137
+ self.connection = connection
138
+ self.closed = False
139
+
140
+ def cursor(self):
141
+ return Cursor(self.connection)
142
+
143
+ def commit(self):
144
+ cur = self.connection.get_cursor()
145
+ cur.prepare("COMMIT")
146
+ cur.exec()
147
+ # self.connection.exec("COMMIT")
148
+
149
+ def rollback(self):
150
+ self.connection.exec("ROLLBACK")
151
+
152
+ def close(self):
153
+ if not self.closed:
154
+ self.connection.close()
155
+ self.closed = True
156
+
157
+ def __enter__(self):
158
+ return self
159
+
160
+ def __exit__(self, *exc):
161
+ self.close()
162
+ return False
163
+
164
+
165
+ def connect(dsn=None, config=None, **kwargs):
166
+ """Open an Oracle connection.
167
+
168
+ dsn: oracle://user:pass@host:port/service?OPTION=value
169
+ Returns a DB-API-style ConnectionWrapper with .cursor(), .commit(), .close().
170
+ The underlying driver Connection is at `.connection`.
171
+ """
172
+ if config is None and dsn is None:
173
+ raise ValueError("dsn or config required")
174
+ conn = Connection(dsn=dsn, config=config)
175
+ if dsn:
176
+ if hasattr(dsn, "form"):
177
+ pass
178
+ if kwargs:
179
+ cfg = conn.conn_option
180
+ for k, v in kwargs.items():
181
+ if hasattr(cfg, k):
182
+ setattr(cfg, k, v)
183
+ try:
184
+ conn.connect()
185
+ except Exception:
186
+ try:
187
+ conn.close()
188
+ except Exception:
189
+ pass
190
+ raise
191
+ return ConnectionWrapper(conn)