oracle-driver 1.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.
- oracle_driver-1.0.0/LICENSE +26 -0
- oracle_driver-1.0.0/PKG-INFO +169 -0
- oracle_driver-1.0.0/README.md +143 -0
- oracle_driver-1.0.0/oracle_driver.egg-info/PKG-INFO +169 -0
- oracle_driver-1.0.0/oracle_driver.egg-info/SOURCES.txt +37 -0
- oracle_driver-1.0.0/oracle_driver.egg-info/dependency_links.txt +1 -0
- oracle_driver-1.0.0/oracle_driver.egg-info/top_level.txt +1 -0
- oracle_driver-1.0.0/pyora/__init__.py +191 -0
- oracle_driver-1.0.0/pyora/advanced_nego.py +402 -0
- oracle_driver-1.0.0/pyora/auth_object.py +373 -0
- oracle_driver-1.0.0/pyora/command.py +675 -0
- oracle_driver-1.0.0/pyora/configurations.py +439 -0
- oracle_driver-1.0.0/pyora/connection.py +400 -0
- oracle_driver-1.0.0/pyora/converters/__init__.py +7 -0
- oracle_driver-1.0.0/pyora/converters/number.py +298 -0
- oracle_driver-1.0.0/pyora/converters/strings.py +111 -0
- oracle_driver-1.0.0/pyora/converters/type_conversion.py +297 -0
- oracle_driver-1.0.0/pyora/converters/types_const.py +68 -0
- oracle_driver-1.0.0/pyora/data_set.py +145 -0
- oracle_driver-1.0.0/pyora/data_type_nego.py +327 -0
- oracle_driver-1.0.0/pyora/db_version.py +45 -0
- oracle_driver-1.0.0/pyora/network/__init__.py +1 -0
- oracle_driver-1.0.0/pyora/network/accept_packet.py +53 -0
- oracle_driver-1.0.0/pyora/network/connect_packet.py +52 -0
- oracle_driver-1.0.0/pyora/network/data_packet.py +62 -0
- oracle_driver-1.0.0/pyora/network/marker_packet.py +40 -0
- oracle_driver-1.0.0/pyora/network/oracle_error.py +68 -0
- oracle_driver-1.0.0/pyora/network/packets.py +49 -0
- oracle_driver-1.0.0/pyora/network/refuse_packet.py +79 -0
- oracle_driver-1.0.0/pyora/network/session.py +539 -0
- oracle_driver-1.0.0/pyora/network/session_ctx.py +56 -0
- oracle_driver-1.0.0/pyora/network/summary_object.py +138 -0
- oracle_driver-1.0.0/pyora/oracle_type.py +121 -0
- oracle_driver-1.0.0/pyora/parameter_encode.py +114 -0
- oracle_driver-1.0.0/pyora/tcp_protocol_nego.py +69 -0
- oracle_driver-1.0.0/pyora/types/__init__.py +1 -0
- oracle_driver-1.0.0/pyproject.toml +38 -0
- oracle_driver-1.0.0/setup.cfg +4 -0
- oracle_driver-1.0.0/tests/test_core.py +160 -0
|
@@ -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,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,143 @@
|
|
|
1
|
+
# pyora — a native pure-Python Oracle driver (port of go-ora v2)
|
|
2
|
+
|
|
3
|
+
`pyora` is a from-scratch, pure-Python reimplementation of the
|
|
4
|
+
[`github.com/sijms/go-ora/v2`](https://github.com/sijms/go-ora/v2) Oracle driver.
|
|
5
|
+
Like go-ora, it is **fully self-contained**: it speaks the Oracle TTC / Net8
|
|
6
|
+
wire protocol directly over TCP and needs **no Oracle Instant Client, no CGO
|
|
7
|
+
counterpart, and no DLL**, so the resulting package is pure Python and portable
|
|
8
|
+
to any platform with CPython.
|
|
9
|
+
|
|
10
|
+
> Scope note: this is the **core working driver** — a faithful port of the
|
|
11
|
+
> connect + O5LOGON authentication + query/execute/fetch + core data-type path
|
|
12
|
+
> that most applications need. The more exotic go-ora subsystems (TLS/Kerberos
|
|
13
|
+
> advanced network services, UDT/XML collection support, vector, bulk copy,
|
|
14
|
+
> streaming CLOB/BLOB fetch) are intentionally out of scope here and documented
|
|
15
|
+
> under *Limitations*.
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
import pyora
|
|
21
|
+
|
|
22
|
+
conn = pyora.connect("oracle://scott:tiger@localhost:1521/XEPDB1")
|
|
23
|
+
cur = conn.cursor()
|
|
24
|
+
cur.execute("SELECT empno, ename, sal FROM emp WHERE deptno = :1", (10,))
|
|
25
|
+
for row in cur:
|
|
26
|
+
print(row)
|
|
27
|
+
cur.close()
|
|
28
|
+
conn.close()
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The connection string follows go-ora's format:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
oracle://user:password@host:port/service_name?OPTION=value
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Supported options (subset of go-ora's): `SID`, `SERVICE NAME`, `INSTANCE NAME`,
|
|
38
|
+
`CHARSET` (e.g. `AL32UTF8`), `CONNSTR` (a full TNS descriptor),
|
|
39
|
+
`SERVER=`*host:port[,host:port]*, `AUTH TYPE` (`OS`/`NORMAL`), `DBA PRIVILEGE`
|
|
40
|
+
(`SYSDBA`/`SYSOPER`/…), `CONNECT TIMEOUT`, `TIMEOUT`, `TRACE FILE DIR`, `LOB FETCH`.
|
|
41
|
+
|
|
42
|
+
The package also exposes the go-ora-style low-level API:
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from pyora.connection import Connection
|
|
46
|
+
conn = Connection("oracle://scott:tiger@localhost:1521/XEPDB1")
|
|
47
|
+
conn.connect()
|
|
48
|
+
rs = conn.query("SELECT name FROM t WHERE id = :1", (42,))
|
|
49
|
+
print(rs.columns()) # [(name, oci_type), ...]
|
|
50
|
+
for row in rs.rows():
|
|
51
|
+
print(row)
|
|
52
|
+
conn.close()
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Architecture (mirrors go-ora v2)
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
pyora/
|
|
59
|
+
__init__.py high-level connect() + DB-API 2.0 style cursor/conn
|
|
60
|
+
configurations.py DSN parsing + TNS connect descriptor generation
|
|
61
|
+
(go-ora configurations/connect_config.go)
|
|
62
|
+
connection.py Connection: session, protocol/data-type negotiation,
|
|
63
|
+
O5LOGON auth, version retrieval, query/exec
|
|
64
|
+
(go-ora connection.go)
|
|
65
|
+
auth_object.py O5LOGON / O5AUTH: DES/AES session-key exchange,
|
|
66
|
+
SHA1/PBKDF2 verifiers, speedy-key
|
|
67
|
+
(go-ora auth_object.go)
|
|
68
|
+
tcp_protocol_nego.py TCP protocol negotiation (go-ora tcp_protocol_nego.go)
|
|
69
|
+
data_type_nego.py DTY (data type) negotiation, TZ handshake
|
|
70
|
+
(go-ora data_type_nego.go)
|
|
71
|
+
command.py statement parsing + query/execute/fetch flow
|
|
72
|
+
(go-ora command.go)
|
|
73
|
+
data_set.py Column / DataSet result model (go-ora data_set.go)
|
|
74
|
+
parameter_encode.py bind-parameter wire encoding
|
|
75
|
+
(go-ora parameter_encode.go)
|
|
76
|
+
oracle_type.py TNS/OCI type constants (go-ora parameter.go)
|
|
77
|
+
db_version.py database version retrieval (go-ora db_version.go)
|
|
78
|
+
converters/
|
|
79
|
+
number.py Oracle NUMBER binary <-> int/float/Decimal
|
|
80
|
+
(go-ora number.go / converters/oracle_number.go)
|
|
81
|
+
type_conversion.py column metadata + row value decoding
|
|
82
|
+
(go-ora converters/type_conversion.go, parameter.go)
|
|
83
|
+
strings.py server charset id -> Python codec
|
|
84
|
+
(go-ora converters/string_conversion.go)
|
|
85
|
+
network/
|
|
86
|
+
session.py TTC byte (de)serialization + packet framing
|
|
87
|
+
(go-ora network/session.go)
|
|
88
|
+
packets.py packet types + header layout (go-ora packets.go)
|
|
89
|
+
connect/accept/refuse/redirect/marker/data_packet.py
|
|
90
|
+
session_ctx.py, summary_object.py, oracle_error.py
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Verification
|
|
94
|
+
|
|
95
|
+
The port ships a consolidated byte-level verification suite that runs without a
|
|
96
|
+
live Oracle:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
python -m tests.test_core # 29 checks: NUMBER, config, CLR, packets, strings, binds
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Run on Windows with `PYTHONIOENCODING=utf-8` if your console is a non-UTF-8
|
|
103
|
+
codepage.
|
|
104
|
+
|
|
105
|
+
A live end-to-end check against a real Oracle instance (`CONNECTED`, `SELECT 1`,
|
|
106
|
+
and a multi-row/multi-column data query over VARCHAR2/DATE/NUMBER with NULL
|
|
107
|
+
handling) passes on Oracle 11g (192.168.30.182:11521, SID `orcl`).
|
|
108
|
+
|
|
109
|
+
## Data-type coverage
|
|
110
|
+
|
|
111
|
+
| Oracle type | Python value |
|
|
112
|
+
|--------------------------|--------------|
|
|
113
|
+
| NUMBER / FLOAT / BINTEGER| `int`, `float`, `decimal.Decimal` |
|
|
114
|
+
| VARCHAR2 / CHAR / LONG | `str` (charset-aware) |
|
|
115
|
+
| RAW / LONG RAW | `bytes` |
|
|
116
|
+
| DATE | `datetime.datetime` (year §100-format, BC→year≤0) |
|
|
117
|
+
| TIMESTAMP / TIMESTAMP TZ / LTZ | `datetime.datetime` (µs) |
|
|
118
|
+
| ROWID / UROWID | `str` |
|
|
119
|
+
| BOOLEAN | `bool` |
|
|
120
|
+
| NULL | `None` |
|
|
121
|
+
| CLOB / BLOB | inline bytes/str (locator returned) |
|
|
122
|
+
|
|
123
|
+
## Limitations (deliberately out of the core scope)
|
|
124
|
+
|
|
125
|
+
- **Advanced network services** (TLS, Kerberos, AES network encryption beyond
|
|
126
|
+
the O5LOGON session-key exchange) are not implemented. Plain TCP to a server
|
|
127
|
+
that does not *require* advanced services works; it will not interoperate
|
|
128
|
+
with a database configured to mandate encryption/NTS auth.
|
|
129
|
+
- **Bind parameters in `Command.writePars`** and **LOBFETCH / subsequent row
|
|
130
|
+
batches** are stubbed (`NotImplementedError` / `fetch_more` TODO) — the
|
|
131
|
+
implemented path covers non-parameterized SQL and the inline-first-batch
|
|
132
|
+
fetch. The `execute`/`query` DB-API helpers currently bind positional params
|
|
133
|
+
for the common in-memory case.
|
|
134
|
+
- UDT/collection/ref-cursor, vector, and bulk-copy paths are not ported.
|
|
135
|
+
- Existing validation is byte-level (wire-format vectors + round-trips); a live
|
|
136
|
+
Oracle is needed to confirm the full connect handshake against a real server.
|
|
137
|
+
|
|
138
|
+
## License
|
|
139
|
+
|
|
140
|
+
This is an independent clean-room-style port of the go-ora v2 wire protocol.
|
|
141
|
+
go-ora is MIT-licensed; please retain the upstream attribution for the protocol
|
|
142
|
+
work it represents. See `LICENSE` of the upstream
|
|
143
|
+
[`sijms/go-ora`](https://github.com/sijms/go-ora) repository.
|
|
@@ -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,37 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
oracle_driver.egg-info/PKG-INFO
|
|
5
|
+
oracle_driver.egg-info/SOURCES.txt
|
|
6
|
+
oracle_driver.egg-info/dependency_links.txt
|
|
7
|
+
oracle_driver.egg-info/top_level.txt
|
|
8
|
+
pyora/__init__.py
|
|
9
|
+
pyora/advanced_nego.py
|
|
10
|
+
pyora/auth_object.py
|
|
11
|
+
pyora/command.py
|
|
12
|
+
pyora/configurations.py
|
|
13
|
+
pyora/connection.py
|
|
14
|
+
pyora/data_set.py
|
|
15
|
+
pyora/data_type_nego.py
|
|
16
|
+
pyora/db_version.py
|
|
17
|
+
pyora/oracle_type.py
|
|
18
|
+
pyora/parameter_encode.py
|
|
19
|
+
pyora/tcp_protocol_nego.py
|
|
20
|
+
pyora/converters/__init__.py
|
|
21
|
+
pyora/converters/number.py
|
|
22
|
+
pyora/converters/strings.py
|
|
23
|
+
pyora/converters/type_conversion.py
|
|
24
|
+
pyora/converters/types_const.py
|
|
25
|
+
pyora/network/__init__.py
|
|
26
|
+
pyora/network/accept_packet.py
|
|
27
|
+
pyora/network/connect_packet.py
|
|
28
|
+
pyora/network/data_packet.py
|
|
29
|
+
pyora/network/marker_packet.py
|
|
30
|
+
pyora/network/oracle_error.py
|
|
31
|
+
pyora/network/packets.py
|
|
32
|
+
pyora/network/refuse_packet.py
|
|
33
|
+
pyora/network/session.py
|
|
34
|
+
pyora/network/session_ctx.py
|
|
35
|
+
pyora/network/summary_object.py
|
|
36
|
+
pyora/types/__init__.py
|
|
37
|
+
tests/test_core.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pyora
|