Skip to content

Commit 4f7e9b6

Browse files
The connect() and create_pool() functions now have complete
documentation on their arguments.
1 parent a5c0c6f commit 4f7e9b6

File tree

12 files changed

+2316
-263
lines changed

12 files changed

+2316
-263
lines changed

doc/src/release_notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ Common Changes
3737
#) The compiler flag ``-arch x86_64`` no longer needs to be explicitly
3838
specified when building from source code on macOS (Intel x86) without
3939
Universal Python binaries.
40+
#) The connect() and create_pool() functions now have complete documentation
41+
on their arguments.
4042
#) Improved samples and documentation.
4143

4244

src/oracledb/connect_params.py

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ def __init__(self, *,
8989
handle: int=0,
9090
threaded: bool=True,
9191
encoding: str=None,
92-
nencoding: str=None):
92+
nencoding: str=None
93+
):
9394
"""
9495
All parameters are optional. A brief description of each parameter
9596
follows:
@@ -229,39 +230,40 @@ def __init__(self, *,
229230
pass
230231

231232
def __repr__(self):
232-
return self.__class__.__qualname__ + \
233-
f"(user={self.user!r}" + \
234-
f", proxy_user={self.proxy_user!r}" + \
235-
f", host={self.host!r}" + \
236-
f", port={self.port!r}" + \
237-
f", protocol={self.protocol!r}" + \
238-
f", https_proxy={self.https_proxy!r}" + \
239-
f", https_proxy_port={self.https_proxy_port!r}" + \
240-
f", service_name={self.service_name!r}" + \
241-
f", sid={self.sid!r}" + \
242-
f", server_type={self.server_type!r}" + \
243-
f", cclass={self.cclass!r}" + \
244-
f", purity={self.purity!r}" + \
245-
f", expire_time={self.expire_time!r}" + \
246-
f", retry_count={self.retry_count!r}" + \
247-
f", retry_delay={self.retry_delay!r}" + \
248-
f", tcp_connect_timeout={self.tcp_connect_timeout!r}" + \
249-
f", ssl_server_dn_match={self.ssl_server_dn_match!r}" + \
250-
f", ssl_server_cert_dn={self.ssl_server_cert_dn!r}" + \
251-
f", wallet_location={self.wallet_location!r}" + \
252-
f", events={self.events!r}" + \
253-
f", externalauth={self.externalauth!r}" + \
254-
f", mode={self.mode!r}" + \
255-
f", disable_oob={self.disable_oob!r}" + \
256-
f", stmtcachesize={self.stmtcachesize!r}" + \
257-
f", edition={self.edition!r}" + \
258-
f", tag={self.tag!r}" + \
259-
f", matchanytag={self.matchanytag!r}" + \
260-
f", config_dir={self.config_dir!r}" + \
261-
f", appcontext={self.appcontext!r}" + \
262-
f", shardingkey={self.shardingkey!r}" + \
263-
f", supershardingkey={self.supershardingkey!r}" + \
264-
f", debug_jdwp={self.debug_jdwp!r})"
233+
return self.__class__.__qualname__ + "(" + \
234+
f"user={self.user!r}, " + \
235+
f"proxy_user={self.proxy_user!r}, " + \
236+
f"host={self.host!r}, " + \
237+
f"port={self.port!r}, " + \
238+
f"protocol={self.protocol!r}, " + \
239+
f"https_proxy={self.https_proxy!r}, " + \
240+
f"https_proxy_port={self.https_proxy_port!r}, " + \
241+
f"service_name={self.service_name!r}, " + \
242+
f"sid={self.sid!r}, " + \
243+
f"server_type={self.server_type!r}, " + \
244+
f"cclass={self.cclass!r}, " + \
245+
f"purity={self.purity!r}, " + \
246+
f"expire_time={self.expire_time!r}, " + \
247+
f"retry_count={self.retry_count!r}, " + \
248+
f"retry_delay={self.retry_delay!r}, " + \
249+
f"tcp_connect_timeout={self.tcp_connect_timeout!r}, " + \
250+
f"ssl_server_dn_match={self.ssl_server_dn_match!r}, " + \
251+
f"ssl_server_cert_dn={self.ssl_server_cert_dn!r}, " + \
252+
f"wallet_location={self.wallet_location!r}, " + \
253+
f"events={self.events!r}, " + \
254+
f"externalauth={self.externalauth!r}, " + \
255+
f"mode={self.mode!r}, " + \
256+
f"disable_oob={self.disable_oob!r}, " + \
257+
f"stmtcachesize={self.stmtcachesize!r}, " + \
258+
f"edition={self.edition!r}, " + \
259+
f"tag={self.tag!r}, " + \
260+
f"matchanytag={self.matchanytag!r}, " + \
261+
f"config_dir={self.config_dir!r}, " + \
262+
f"appcontext={self.appcontext!r}, " + \
263+
f"shardingkey={self.shardingkey!r}, " + \
264+
f"supershardingkey={self.supershardingkey!r}, " + \
265+
f"debug_jdwp={self.debug_jdwp!r}" + \
266+
")"
265267

266268
def _address_attr(f):
267269
"""
@@ -629,7 +631,8 @@ def set(self, *,
629631
handle: int=None,
630632
threaded: bool=None,
631633
encoding: str=None,
632-
nencoding: str=None):
634+
nencoding: str=None
635+
):
633636
"""
634637
All parameters are optional. A brief description of each parameter
635638
follows:

src/oracledb/connection.py

Lines changed: 157 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,17 @@
2727
#
2828
# Contains the Connection class and the factory method connect() used for
2929
# establishing connections to the database.
30+
#
31+
# *** NOTICE *** This file is generated from a template and should not be
32+
# modified directly. See build_from_template.py in the utils subdirectory for
33+
# more information.
3034
#------------------------------------------------------------------------------
3135

3236
import collections
3337
import functools
3438

39+
import oracledb
40+
3541
from . import __name__ as MODULE_NAME
3642

3743
from typing import Any, Callable, Type, Union
@@ -1006,53 +1012,46 @@ def connect(dsn: str=None, *,
10061012
pool: Type["pool_module.ConnectionPool"]=None,
10071013
conn_class: Type[Connection]=Connection,
10081014
params: ConnectParams=None,
1009-
1010-
# credentials
10111015
user: str=None,
10121016
proxy_user: str=None,
10131017
password: str=None,
10141018
newpassword: str=None,
10151019
wallet_password: str=None,
1016-
1017-
# connect string parameters
10181020
host: str=None,
1019-
port: int=None,
1020-
protocol: str=None,
1021+
port: int=1521,
1022+
protocol: str="tcp",
10211023
https_proxy: str=None,
1022-
https_proxy_port: int=None,
1024+
https_proxy_port: int=0,
10231025
service_name: str=None,
10241026
sid: str=None,
10251027
server_type: str=None,
10261028
cclass: str=None,
1027-
purity: int=None,
1028-
expire_time: int=None,
1029-
retry_count: int=None,
1030-
retry_delay: int=None,
1031-
tcp_connect_timeout: float=None,
1032-
ssl_server_dn_match: bool=None,
1029+
purity: int=oracledb.PURITY_DEFAULT,
1030+
expire_time: int=0,
1031+
retry_count: int=0,
1032+
retry_delay: int=0,
1033+
tcp_connect_timeout: float=60.0,
1034+
ssl_server_dn_match: bool=True,
10331035
ssl_server_cert_dn: str=None,
10341036
wallet_location: str=None,
1035-
1036-
# other parameters
1037-
events: bool=None,
1038-
externalauth: bool=None,
1039-
mode: int=None,
1040-
disable_oob: bool=None,
1041-
stmtcachesize: int=None,
1037+
events: bool=False,
1038+
externalauth: bool=False,
1039+
mode: int=oracledb.AUTH_MODE_DEFAULT,
1040+
disable_oob: bool=False,
1041+
stmtcachesize: int=oracledb.defaults.stmtcachesize,
10421042
edition: str=None,
10431043
tag: str=None,
1044-
matchanytag: bool=None,
1045-
config_dir: str=None,
1044+
matchanytag: bool=False,
1045+
config_dir: str=oracledb.defaults.config_dir,
10461046
appcontext: list=None,
10471047
shardingkey: list=None,
10481048
supershardingkey: list=None,
10491049
debug_jdwp: str=None,
1050-
handle: int=None,
1051-
1052-
# deprecated (ignored) parameters
1053-
threaded: bool=None,
1050+
handle: int=0,
1051+
threaded: bool=True,
10541052
encoding: str=None,
1055-
nencoding: str=None) -> Connection:
1053+
nencoding: str=None
1054+
) -> Connection:
10561055
"""
10571056
Factory function which creates a connection to the database and returns it.
10581057
@@ -1079,5 +1078,136 @@ def connect(dsn: str=None, *,
10791078
specified (if any) within the dsn will override the values passed as
10801079
additional keyword parameters, which themselves override the values set in
10811080
the params parameter object.
1081+
1082+
The following parameters are all optional. A brief description of each
1083+
parameter follows:
1084+
1085+
- user: the name of the user to connect to (default: None)
1086+
1087+
- proxy_user: the name of the proxy user to connect to. If this value is
1088+
not specified, it will be parsed out of user if user is in the form
1089+
"user[proxy_user]" (default: None)
1090+
1091+
- password: the password for the user (default: None)
1092+
1093+
- newpassword: the new password for the user. The new password will take
1094+
effect immediately upon a successful connection to the database (default:
1095+
None)
1096+
1097+
- wallet_password: the password to use to decrypt the wallet, if it is
1098+
encrypted. This value is only used in thin mode (default: None)
1099+
1100+
- host: the name or IP address of the machine hosting the database or the
1101+
database listener (default: None)
1102+
1103+
- port: the port number on which the database listener is listening
1104+
(default: 1521)
1105+
1106+
- protocol: one of the strings "tcp" or "tcps" indicating whether to use
1107+
unencrypted network traffic or encrypted network traffic (TLS) (default:
1108+
"tcp")
1109+
1110+
- https_proxy: the name or IP address of a proxy host to use for tunneling
1111+
secure connections (default: None)
1112+
1113+
- https_proxy_port: the port on which to communicate with the proxy host
1114+
(default: 0)
1115+
1116+
- service_name: the service name of the database (default: None)
1117+
1118+
- sid: the system identifier (SID) of the database. Note using a
1119+
service_name instead is recommended (default: None)
1120+
1121+
- server_type: the type of server connection that should be established. If
1122+
specified, it should be one of "dedicated", "shared" or "pooled"
1123+
(default: None)
1124+
1125+
- cclass: connection class to use for Database Resident Connection Pooling
1126+
(DRCP) (default: None)
1127+
1128+
- purity: purity to use for Database Resident Connection Pooling (DRCP)
1129+
(default: oracledb.PURITY_DEFAULT)
1130+
1131+
- expire_time: an integer indicating the number of minutes between the
1132+
sending of keepalive probes. If this parameter is set to a value greater
1133+
than zero it enables keepalive (default: 0)
1134+
1135+
- retry_count: the number of times that a connection attempt should be
1136+
retried before the attempt is terminated (default: 0)
1137+
1138+
- retry_delay: the number of seconds to wait before making a new connection
1139+
attempt (default: 0)
1140+
1141+
- tcp_connect_timeout: a float indicating the maximum number of seconds to
1142+
wait for establishing a connection to the database host (default: 60.0)
1143+
1144+
- ssl_server_dn_match: boolean indicating whether the server certificate
1145+
distinguished name (DN) should be matched in addition to the regular
1146+
certificate verification that is performed. Note that if the
1147+
ssl_server_cert_dn parameter is not privided, host name matching is
1148+
performed instead (default: True)
1149+
1150+
- ssl_server_cert_dn: the distinguished name (DN) which should be matched
1151+
with the server. This value is ignored if the ssl_server_dn_match
1152+
parameter is not set to the value True. If specified this value is used
1153+
for any verfication. Otherwise the hostname will be used. (default: None)
1154+
1155+
- wallet_location: the directory where the wallet can be found. In thin
1156+
mode this must be the directory containing the PEM-encoded wallet file
1157+
ewallet.pem. In thick mode this must be the directory containing the file
1158+
cwallet.sso (default: None)
1159+
1160+
- events: boolean specifying whether events mode should be enabled. This
1161+
value is only used in thick mode and is needed for continuous query
1162+
notification and high availability event notifications (default: False)
1163+
1164+
- externalauth: a boolean indicating whether to use external authentication
1165+
(default: False)
1166+
1167+
- mode: authorization mode to use. For example oracledb.AUTH_MODE_SYSDBA
1168+
(default: oracledb.AUTH_MODE_DEFAULT)
1169+
1170+
- disable_oob: boolean indicating whether out-of-band breaks should be
1171+
disabled. This value is only used in thin mode. It has no effect on
1172+
Windows which does not support this functionality (default: False)
1173+
1174+
- stmtcachesize: identifies the initial size of the statement cache
1175+
(default: oracledb.defaults.stmtcachesize)
1176+
1177+
- edition: edition to use for the connection. This parameter cannot be used
1178+
simultaneously with the cclass parameter (default: None)
1179+
1180+
- tag: identifies the type of connection that should be returned from a
1181+
pool. This value is only used in thick mode (default: None)
1182+
1183+
- matchanytag: boolean specifying whether any tag can be used when
1184+
acquiring a connection from the pool. This value is only used in thick
1185+
mode. (default: False)
1186+
1187+
- config_dir: directory in which the optional tnsnames.ora configuration
1188+
file is located. This value is only used in thin mode. For thick mode use
1189+
the config_dir parameter of init_oracle_client() (default:
1190+
oracledb.defaults.config_dir)
1191+
1192+
- appcontext: application context used by the connection. It should be a
1193+
list of 3-tuples (namespace, name, value) and each entry in the tuple
1194+
should be a string. This value is only used in thick mode (default: None)
1195+
1196+
- shardingkey: a list of strings, numbers, bytes or dates that identify the
1197+
database shard to connect to. This value is only used in thick mode
1198+
(default: None)
1199+
1200+
- supershardingkey: a list of strings, numbers, bytes or dates that
1201+
identify the database shard to connect to. This value is only used in
1202+
thick mode (default: None)
1203+
1204+
- debug_jdwp: a string with the format "host=<host>;port=<port>" that
1205+
specifies the host and port of the PL/SQL debugger. This value is only
1206+
used in thin mode. For thick mode set the ORA_DEBUG_JDWP environment
1207+
variable (default: None)
1208+
1209+
- handle: an integer representing a pointer to a valid service context
1210+
handle. This value is only used in thick mode. It should be used with
1211+
extreme caution (default: 0)
10821212
"""
10831213
pass

0 commit comments

Comments
 (0)