sqlspec 0.14.1__py3-none-any.whl → 0.15.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.

Potentially problematic release.


This version of sqlspec might be problematic. Click here for more details.

Files changed (158) hide show
  1. sqlspec/__init__.py +50 -25
  2. sqlspec/__main__.py +1 -1
  3. sqlspec/__metadata__.py +1 -3
  4. sqlspec/_serialization.py +1 -2
  5. sqlspec/_sql.py +256 -120
  6. sqlspec/_typing.py +278 -142
  7. sqlspec/adapters/adbc/__init__.py +4 -3
  8. sqlspec/adapters/adbc/_types.py +12 -0
  9. sqlspec/adapters/adbc/config.py +115 -260
  10. sqlspec/adapters/adbc/driver.py +462 -367
  11. sqlspec/adapters/aiosqlite/__init__.py +18 -3
  12. sqlspec/adapters/aiosqlite/_types.py +13 -0
  13. sqlspec/adapters/aiosqlite/config.py +199 -129
  14. sqlspec/adapters/aiosqlite/driver.py +230 -269
  15. sqlspec/adapters/asyncmy/__init__.py +18 -3
  16. sqlspec/adapters/asyncmy/_types.py +12 -0
  17. sqlspec/adapters/asyncmy/config.py +80 -168
  18. sqlspec/adapters/asyncmy/driver.py +260 -225
  19. sqlspec/adapters/asyncpg/__init__.py +19 -4
  20. sqlspec/adapters/asyncpg/_types.py +17 -0
  21. sqlspec/adapters/asyncpg/config.py +82 -181
  22. sqlspec/adapters/asyncpg/driver.py +285 -383
  23. sqlspec/adapters/bigquery/__init__.py +17 -3
  24. sqlspec/adapters/bigquery/_types.py +12 -0
  25. sqlspec/adapters/bigquery/config.py +191 -258
  26. sqlspec/adapters/bigquery/driver.py +474 -646
  27. sqlspec/adapters/duckdb/__init__.py +14 -3
  28. sqlspec/adapters/duckdb/_types.py +12 -0
  29. sqlspec/adapters/duckdb/config.py +415 -351
  30. sqlspec/adapters/duckdb/driver.py +343 -413
  31. sqlspec/adapters/oracledb/__init__.py +19 -5
  32. sqlspec/adapters/oracledb/_types.py +14 -0
  33. sqlspec/adapters/oracledb/config.py +123 -379
  34. sqlspec/adapters/oracledb/driver.py +507 -560
  35. sqlspec/adapters/psqlpy/__init__.py +13 -3
  36. sqlspec/adapters/psqlpy/_types.py +11 -0
  37. sqlspec/adapters/psqlpy/config.py +93 -254
  38. sqlspec/adapters/psqlpy/driver.py +505 -234
  39. sqlspec/adapters/psycopg/__init__.py +19 -5
  40. sqlspec/adapters/psycopg/_types.py +17 -0
  41. sqlspec/adapters/psycopg/config.py +143 -403
  42. sqlspec/adapters/psycopg/driver.py +706 -872
  43. sqlspec/adapters/sqlite/__init__.py +14 -3
  44. sqlspec/adapters/sqlite/_types.py +11 -0
  45. sqlspec/adapters/sqlite/config.py +202 -118
  46. sqlspec/adapters/sqlite/driver.py +264 -303
  47. sqlspec/base.py +105 -9
  48. sqlspec/{statement/builder → builder}/__init__.py +12 -14
  49. sqlspec/{statement/builder → builder}/_base.py +120 -55
  50. sqlspec/{statement/builder → builder}/_column.py +17 -6
  51. sqlspec/{statement/builder → builder}/_ddl.py +46 -79
  52. sqlspec/{statement/builder → builder}/_ddl_utils.py +5 -10
  53. sqlspec/{statement/builder → builder}/_delete.py +6 -25
  54. sqlspec/{statement/builder → builder}/_insert.py +6 -64
  55. sqlspec/builder/_merge.py +56 -0
  56. sqlspec/{statement/builder → builder}/_parsing_utils.py +3 -10
  57. sqlspec/{statement/builder → builder}/_select.py +11 -56
  58. sqlspec/{statement/builder → builder}/_update.py +12 -18
  59. sqlspec/{statement/builder → builder}/mixins/__init__.py +10 -14
  60. sqlspec/{statement/builder → builder}/mixins/_cte_and_set_ops.py +48 -59
  61. sqlspec/{statement/builder → builder}/mixins/_insert_operations.py +22 -16
  62. sqlspec/{statement/builder → builder}/mixins/_join_operations.py +1 -3
  63. sqlspec/{statement/builder → builder}/mixins/_merge_operations.py +3 -5
  64. sqlspec/{statement/builder → builder}/mixins/_order_limit_operations.py +3 -3
  65. sqlspec/{statement/builder → builder}/mixins/_pivot_operations.py +4 -8
  66. sqlspec/{statement/builder → builder}/mixins/_select_operations.py +21 -36
  67. sqlspec/{statement/builder → builder}/mixins/_update_operations.py +3 -14
  68. sqlspec/{statement/builder → builder}/mixins/_where_clause.py +52 -79
  69. sqlspec/cli.py +4 -5
  70. sqlspec/config.py +180 -133
  71. sqlspec/core/__init__.py +63 -0
  72. sqlspec/core/cache.py +873 -0
  73. sqlspec/core/compiler.py +396 -0
  74. sqlspec/core/filters.py +828 -0
  75. sqlspec/core/hashing.py +310 -0
  76. sqlspec/core/parameters.py +1209 -0
  77. sqlspec/core/result.py +664 -0
  78. sqlspec/{statement → core}/splitter.py +321 -191
  79. sqlspec/core/statement.py +651 -0
  80. sqlspec/driver/__init__.py +7 -10
  81. sqlspec/driver/_async.py +387 -176
  82. sqlspec/driver/_common.py +527 -289
  83. sqlspec/driver/_sync.py +390 -172
  84. sqlspec/driver/mixins/__init__.py +2 -19
  85. sqlspec/driver/mixins/_result_tools.py +168 -0
  86. sqlspec/driver/mixins/_sql_translator.py +6 -3
  87. sqlspec/exceptions.py +5 -252
  88. sqlspec/extensions/aiosql/adapter.py +93 -96
  89. sqlspec/extensions/litestar/config.py +0 -1
  90. sqlspec/extensions/litestar/handlers.py +15 -26
  91. sqlspec/extensions/litestar/plugin.py +16 -14
  92. sqlspec/extensions/litestar/providers.py +17 -52
  93. sqlspec/loader.py +424 -105
  94. sqlspec/migrations/__init__.py +12 -0
  95. sqlspec/migrations/base.py +92 -68
  96. sqlspec/migrations/commands.py +24 -106
  97. sqlspec/migrations/loaders.py +402 -0
  98. sqlspec/migrations/runner.py +49 -51
  99. sqlspec/migrations/tracker.py +31 -44
  100. sqlspec/migrations/utils.py +64 -24
  101. sqlspec/protocols.py +7 -183
  102. sqlspec/storage/__init__.py +1 -1
  103. sqlspec/storage/backends/base.py +37 -40
  104. sqlspec/storage/backends/fsspec.py +136 -112
  105. sqlspec/storage/backends/obstore.py +138 -160
  106. sqlspec/storage/capabilities.py +5 -4
  107. sqlspec/storage/registry.py +57 -106
  108. sqlspec/typing.py +136 -115
  109. sqlspec/utils/__init__.py +2 -3
  110. sqlspec/utils/correlation.py +0 -3
  111. sqlspec/utils/deprecation.py +6 -6
  112. sqlspec/utils/fixtures.py +6 -6
  113. sqlspec/utils/logging.py +0 -2
  114. sqlspec/utils/module_loader.py +7 -12
  115. sqlspec/utils/singleton.py +0 -1
  116. sqlspec/utils/sync_tools.py +16 -37
  117. sqlspec/utils/text.py +12 -51
  118. sqlspec/utils/type_guards.py +443 -232
  119. {sqlspec-0.14.1.dist-info → sqlspec-0.15.0.dist-info}/METADATA +7 -2
  120. sqlspec-0.15.0.dist-info/RECORD +134 -0
  121. sqlspec/adapters/adbc/transformers.py +0 -108
  122. sqlspec/driver/connection.py +0 -207
  123. sqlspec/driver/mixins/_cache.py +0 -114
  124. sqlspec/driver/mixins/_csv_writer.py +0 -91
  125. sqlspec/driver/mixins/_pipeline.py +0 -508
  126. sqlspec/driver/mixins/_query_tools.py +0 -796
  127. sqlspec/driver/mixins/_result_utils.py +0 -138
  128. sqlspec/driver/mixins/_storage.py +0 -912
  129. sqlspec/driver/mixins/_type_coercion.py +0 -128
  130. sqlspec/driver/parameters.py +0 -138
  131. sqlspec/statement/__init__.py +0 -21
  132. sqlspec/statement/builder/_merge.py +0 -95
  133. sqlspec/statement/cache.py +0 -50
  134. sqlspec/statement/filters.py +0 -625
  135. sqlspec/statement/parameters.py +0 -956
  136. sqlspec/statement/pipelines/__init__.py +0 -210
  137. sqlspec/statement/pipelines/analyzers/__init__.py +0 -9
  138. sqlspec/statement/pipelines/analyzers/_analyzer.py +0 -646
  139. sqlspec/statement/pipelines/context.py +0 -109
  140. sqlspec/statement/pipelines/transformers/__init__.py +0 -7
  141. sqlspec/statement/pipelines/transformers/_expression_simplifier.py +0 -88
  142. sqlspec/statement/pipelines/transformers/_literal_parameterizer.py +0 -1247
  143. sqlspec/statement/pipelines/transformers/_remove_comments_and_hints.py +0 -76
  144. sqlspec/statement/pipelines/validators/__init__.py +0 -23
  145. sqlspec/statement/pipelines/validators/_dml_safety.py +0 -290
  146. sqlspec/statement/pipelines/validators/_parameter_style.py +0 -370
  147. sqlspec/statement/pipelines/validators/_performance.py +0 -714
  148. sqlspec/statement/pipelines/validators/_security.py +0 -967
  149. sqlspec/statement/result.py +0 -435
  150. sqlspec/statement/sql.py +0 -1774
  151. sqlspec/utils/cached_property.py +0 -25
  152. sqlspec/utils/statement_hashing.py +0 -203
  153. sqlspec-0.14.1.dist-info/RECORD +0 -145
  154. /sqlspec/{statement/builder → builder}/mixins/_delete_operations.py +0 -0
  155. {sqlspec-0.14.1.dist-info → sqlspec-0.15.0.dist-info}/WHEEL +0 -0
  156. {sqlspec-0.14.1.dist-info → sqlspec-0.15.0.dist-info}/entry_points.txt +0 -0
  157. {sqlspec-0.14.1.dist-info → sqlspec-0.15.0.dist-info}/licenses/LICENSE +0 -0
  158. {sqlspec-0.14.1.dist-info → sqlspec-0.15.0.dist-info}/licenses/NOTICE +0 -0
@@ -1,18 +1,32 @@
1
- from sqlspec.adapters.oracledb.config import CONNECTION_FIELDS, POOL_FIELDS, OracleAsyncConfig, OracleSyncConfig
1
+ from sqlspec.adapters.oracledb._types import OracleAsyncConnection, OracleSyncConnection
2
+ from sqlspec.adapters.oracledb.config import (
3
+ OracleAsyncConfig,
4
+ OracleConnectionParams,
5
+ OraclePoolParams,
6
+ OracleSyncConfig,
7
+ )
2
8
  from sqlspec.adapters.oracledb.driver import (
3
- OracleAsyncConnection,
9
+ OracleAsyncCursor,
4
10
  OracleAsyncDriver,
5
- OracleSyncConnection,
11
+ OracleAsyncExceptionHandler,
12
+ OracleSyncCursor,
6
13
  OracleSyncDriver,
14
+ OracleSyncExceptionHandler,
15
+ oracledb_statement_config,
7
16
  )
8
17
 
9
18
  __all__ = (
10
- "CONNECTION_FIELDS",
11
- "POOL_FIELDS",
12
19
  "OracleAsyncConfig",
13
20
  "OracleAsyncConnection",
21
+ "OracleAsyncCursor",
14
22
  "OracleAsyncDriver",
23
+ "OracleAsyncExceptionHandler",
24
+ "OracleConnectionParams",
25
+ "OraclePoolParams",
15
26
  "OracleSyncConfig",
16
27
  "OracleSyncConnection",
28
+ "OracleSyncCursor",
17
29
  "OracleSyncDriver",
30
+ "OracleSyncExceptionHandler",
31
+ "oracledb_statement_config",
18
32
  )
@@ -0,0 +1,14 @@
1
+ from typing import TYPE_CHECKING
2
+
3
+ from oracledb import AsyncConnection, Connection
4
+
5
+ if TYPE_CHECKING:
6
+ from typing_extensions import TypeAlias
7
+
8
+ OracleSyncConnection: TypeAlias = Connection
9
+ OracleAsyncConnection: TypeAlias = AsyncConnection
10
+ else:
11
+ OracleSyncConnection = Connection
12
+ OracleAsyncConnection = AsyncConnection
13
+
14
+ __all__ = ("OracleAsyncConnection", "OracleSyncConnection")
@@ -2,216 +2,122 @@
2
2
 
3
3
  import contextlib
4
4
  import logging
5
- from collections.abc import AsyncGenerator
6
5
  from contextlib import asynccontextmanager
7
- from typing import TYPE_CHECKING, Any, ClassVar, Optional, cast
6
+ from typing import TYPE_CHECKING, Any, ClassVar, Optional, TypedDict, Union, cast
8
7
 
9
8
  import oracledb
9
+ from typing_extensions import NotRequired
10
10
 
11
+ from sqlspec.adapters.oracledb._types import OracleAsyncConnection, OracleSyncConnection
11
12
  from sqlspec.adapters.oracledb.driver import (
12
- OracleAsyncConnection,
13
+ OracleAsyncCursor,
13
14
  OracleAsyncDriver,
14
- OracleSyncConnection,
15
+ OracleSyncCursor,
15
16
  OracleSyncDriver,
17
+ oracledb_statement_config,
16
18
  )
17
19
  from sqlspec.config import AsyncDatabaseConfig, SyncDatabaseConfig
18
- from sqlspec.statement.sql import SQLConfig
19
- from sqlspec.typing import DictRow, Empty
20
20
 
21
21
  if TYPE_CHECKING:
22
- from collections.abc import Callable, Generator
22
+ from collections.abc import AsyncGenerator, Callable, Generator
23
23
 
24
24
  from oracledb import AuthMode
25
25
  from oracledb.pool import AsyncConnectionPool, ConnectionPool
26
26
 
27
+ from sqlspec.core.statement import StatementConfig
27
28
 
28
- __all__ = ("CONNECTION_FIELDS", "POOL_FIELDS", "OracleAsyncConfig", "OracleSyncConfig")
29
+
30
+ __all__ = ("OracleAsyncConfig", "OracleConnectionParams", "OraclePoolParams", "OracleSyncConfig")
29
31
 
30
32
  logger = logging.getLogger(__name__)
31
33
 
32
- CONNECTION_FIELDS = frozenset(
33
- {
34
- "dsn",
35
- "user",
36
- "password",
37
- "host",
38
- "port",
39
- "service_name",
40
- "sid",
41
- "wallet_location",
42
- "wallet_password",
43
- "config_dir",
44
- "tcp_connect_timeout",
45
- "retry_count",
46
- "retry_delay",
47
- "mode",
48
- "events",
49
- "edition",
50
- }
51
- )
52
34
 
53
- POOL_FIELDS = CONNECTION_FIELDS.union(
54
- {
55
- "min",
56
- "max",
57
- "increment",
58
- "threaded",
59
- "getmode",
60
- "homogeneous",
61
- "timeout",
62
- "wait_timeout",
63
- "max_lifetime_session",
64
- "session_callback",
65
- "max_sessions_per_shard",
66
- "soda_metadata_cache",
67
- "ping_interval",
68
- }
69
- )
35
+ class OracleConnectionParams(TypedDict, total=False):
36
+ """OracleDB connection parameters."""
37
+
38
+ dsn: NotRequired[str]
39
+ user: NotRequired[str]
40
+ password: NotRequired[str]
41
+ host: NotRequired[str]
42
+ port: NotRequired[int]
43
+ service_name: NotRequired[str]
44
+ sid: NotRequired[str]
45
+ wallet_location: NotRequired[str]
46
+ wallet_password: NotRequired[str]
47
+ config_dir: NotRequired[str]
48
+ tcp_connect_timeout: NotRequired[float]
49
+ retry_count: NotRequired[int]
50
+ retry_delay: NotRequired[int]
51
+ mode: NotRequired["AuthMode"]
52
+ events: NotRequired[bool]
53
+ edition: NotRequired[str]
54
+
55
+
56
+ class OraclePoolParams(OracleConnectionParams, total=False):
57
+ """OracleDB pool parameters."""
58
+
59
+ min: NotRequired[int]
60
+ max: NotRequired[int]
61
+ increment: NotRequired[int]
62
+ threaded: NotRequired[bool]
63
+ getmode: NotRequired[Any]
64
+ homogeneous: NotRequired[bool]
65
+ timeout: NotRequired[int]
66
+ wait_timeout: NotRequired[int]
67
+ max_lifetime_session: NotRequired[int]
68
+ session_callback: NotRequired["Callable[..., Any]"]
69
+ max_sessions_per_shard: NotRequired[int]
70
+ soda_metadata_cache: NotRequired[bool]
71
+ ping_interval: NotRequired[int]
72
+ extra: NotRequired[dict[str, Any]]
70
73
 
71
74
 
72
75
  class OracleSyncConfig(SyncDatabaseConfig[OracleSyncConnection, "ConnectionPool", OracleSyncDriver]):
73
76
  """Configuration for Oracle synchronous database connections with direct field-based configuration."""
74
77
 
75
- is_async: ClassVar[bool] = False
76
- supports_connection_pooling: ClassVar[bool] = True
77
-
78
- driver_type: type[OracleSyncDriver] = OracleSyncDriver
79
- connection_type: type[OracleSyncConnection] = OracleSyncConnection
80
-
81
- # Parameter style support information
82
- supported_parameter_styles: ClassVar[tuple[str, ...]] = ("named_colon", "positional_colon")
83
- """OracleDB supports :name (named_colon) and :1 (positional_colon) parameter styles."""
84
-
85
- default_parameter_style: ClassVar[str] = "named_colon"
86
- """OracleDB's preferred parameter style is :name (named_colon)."""
78
+ driver_type: ClassVar[type[OracleSyncDriver]] = OracleSyncDriver
79
+ connection_type: "ClassVar[type[OracleSyncConnection]]" = OracleSyncConnection
87
80
 
88
81
  def __init__(
89
82
  self,
90
- statement_config: "Optional[SQLConfig]" = None,
91
- default_row_type: "type[DictRow]" = DictRow,
92
- # Connection parameters
93
- dsn: Optional[str] = None,
94
- user: Optional[str] = None,
95
- password: Optional[str] = None,
96
- host: Optional[str] = None,
97
- port: Optional[int] = None,
98
- service_name: Optional[str] = None,
99
- sid: Optional[str] = None,
100
- wallet_location: Optional[str] = None,
101
- wallet_password: Optional[str] = None,
102
- config_dir: Optional[str] = None,
103
- tcp_connect_timeout: Optional[float] = None,
104
- retry_count: Optional[int] = None,
105
- retry_delay: Optional[int] = None,
106
- mode: Optional["AuthMode"] = None,
107
- events: Optional[bool] = None,
108
- edition: Optional[str] = None,
109
- # Pool parameters
110
- min: Optional[int] = None,
111
- max: Optional[int] = None,
112
- increment: Optional[int] = None,
113
- threaded: Optional[bool] = None,
114
- getmode: Optional[int] = None,
115
- homogeneous: Optional[bool] = None,
116
- timeout: Optional[int] = None,
117
- wait_timeout: Optional[int] = None,
118
- max_lifetime_session: Optional[int] = None,
119
- session_callback: Optional["Callable[[Any, Any], None]"] = None,
120
- max_sessions_per_shard: Optional[int] = None,
121
- soda_metadata_cache: Optional[bool] = None,
122
- ping_interval: Optional[int] = None,
123
- pool_instance: Optional["ConnectionPool"] = None,
124
- **kwargs: Any,
83
+ *,
84
+ pool_instance: "Optional[ConnectionPool]" = None,
85
+ pool_config: "Optional[Union[OraclePoolParams, dict[str, Any]]]" = None,
86
+ statement_config: "Optional[StatementConfig]" = None,
87
+ migration_config: Optional[dict[str, Any]] = None,
125
88
  ) -> None:
126
89
  """Initialize Oracle synchronous configuration.
127
90
 
128
91
  Args:
92
+ pool_config: Pool configuration parameters
93
+ pool_instance: Existing pool instance to use
129
94
  statement_config: Default SQL statement configuration
130
- default_row_type: Default row type for results
131
- dsn: Connection string for the database
132
- user: Username for database authentication
133
- password: Password for database authentication
134
- host: Database server hostname
135
- port: Database server port number
136
- service_name: Oracle service name
137
- sid: Oracle System ID (SID)
138
- wallet_location: Location of Oracle Wallet
139
- wallet_password: Password for accessing Oracle Wallet
140
- config_dir: Directory containing Oracle configuration files
141
- tcp_connect_timeout: Timeout for establishing TCP connections
142
- retry_count: Number of attempts to connect
143
- retry_delay: Time in seconds between connection attempts
144
- mode: Session mode (SYSDBA, SYSOPER, etc.)
145
- events: If True, enables Oracle events for FAN and RLB
146
- edition: Edition name for edition-based redefinition
147
- min: Minimum number of connections in the pool
148
- max: Maximum number of connections in the pool
149
- increment: Number of connections to create when pool needs to grow
150
- threaded: Whether the pool should be threaded
151
- getmode: How connections are returned from the pool
152
- homogeneous: Whether all connections use the same credentials
153
- timeout: Time in seconds after which idle connections are closed
154
- wait_timeout: Time in seconds to wait for an available connection
155
- max_lifetime_session: Maximum time in seconds that a connection can remain in the pool
156
- session_callback: Callback function called when a connection is returned to the pool
157
- max_sessions_per_shard: Maximum number of sessions per shard
158
- soda_metadata_cache: Whether to enable SODA metadata caching
159
- ping_interval: Interval for pinging pooled connections
160
- pool_instance: Optional existing connection pool instance
161
- **kwargs: Additional parameters (stored in extras)
95
+ migration_config: Migration configuration
162
96
  """
163
- # Store connection parameters as instance attributes
164
- self.dsn = dsn
165
- self.user = user
166
- self.password = password
167
- self.host = host
168
- self.port = port
169
- self.service_name = service_name
170
- self.sid = sid
171
- self.wallet_location = wallet_location
172
- self.wallet_password = wallet_password
173
- self.config_dir = config_dir
174
- self.tcp_connect_timeout = tcp_connect_timeout
175
- self.retry_count = retry_count
176
- self.retry_delay = retry_delay
177
- self.mode = mode
178
- self.events = events
179
- self.edition = edition
180
-
181
- # Store pool parameters as instance attributes
182
- self.min = min
183
- self.max = max
184
- self.increment = increment
185
- self.threaded = threaded
186
- self.getmode = getmode
187
- self.homogeneous = homogeneous
188
- self.timeout = timeout
189
- self.wait_timeout = wait_timeout
190
- self.max_lifetime_session = max_lifetime_session
191
- self.session_callback = session_callback
192
- self.max_sessions_per_shard = max_sessions_per_shard
193
- self.soda_metadata_cache = soda_metadata_cache
194
- self.ping_interval = ping_interval
195
-
196
- self.extras = kwargs or {}
197
-
198
- # Store other config
199
- self.statement_config = statement_config or SQLConfig()
200
- self.default_row_type = default_row_type
201
-
202
- super().__init__()
97
+ # Store the pool config as a dict and extract/merge extras
98
+ processed_pool_config: dict[str, Any] = dict(pool_config) if pool_config else {}
99
+ if "extra" in processed_pool_config:
100
+ extras = processed_pool_config.pop("extra")
101
+ processed_pool_config.update(extras)
102
+ statement_config = statement_config or oracledb_statement_config
103
+ super().__init__(
104
+ pool_config=processed_pool_config,
105
+ pool_instance=pool_instance,
106
+ migration_config=migration_config,
107
+ statement_config=statement_config,
108
+ )
203
109
 
204
110
  def _create_pool(self) -> "ConnectionPool":
205
111
  """Create the actual connection pool."""
206
112
 
207
- return oracledb.create_pool(**self.connection_config_dict)
113
+ return oracledb.create_pool(**dict(self.pool_config))
208
114
 
209
115
  def _close_pool(self) -> None:
210
116
  """Close the actual connection pool."""
211
117
  if self.pool_instance:
212
118
  self.pool_instance.close()
213
119
 
214
- def create_connection(self) -> OracleSyncConnection:
120
+ def create_connection(self) -> "OracleSyncConnection":
215
121
  """Create a single connection (not from pool).
216
122
 
217
123
  Returns:
@@ -241,29 +147,21 @@ class OracleSyncConfig(SyncDatabaseConfig[OracleSyncConnection, "ConnectionPool"
241
147
  self.pool_instance.release(conn)
242
148
 
243
149
  @contextlib.contextmanager
244
- def provide_session(self, *args: Any, **kwargs: Any) -> "Generator[OracleSyncDriver, None, None]":
150
+ def provide_session(
151
+ self, *args: Any, statement_config: "Optional[StatementConfig]" = None, **kwargs: Any
152
+ ) -> "Generator[OracleSyncDriver, None, None]":
245
153
  """Provide a driver session context manager.
246
154
 
247
155
  Args:
248
156
  *args: Additional arguments.
157
+ statement_config: Optional statement configuration override.
249
158
  **kwargs: Additional keyword arguments.
250
159
 
251
160
  Yields:
252
161
  An OracleSyncDriver instance.
253
162
  """
254
163
  with self.provide_connection(*args, **kwargs) as conn:
255
- statement_config = self.statement_config
256
- # Inject parameter style info if not already set
257
- if statement_config.allowed_parameter_styles is None:
258
- from dataclasses import replace
259
-
260
- statement_config = replace(
261
- statement_config,
262
- allowed_parameter_styles=self.supported_parameter_styles,
263
- default_parameter_style=self.default_parameter_style,
264
- )
265
- driver = self.driver_type(connection=conn, config=statement_config)
266
- yield driver
164
+ yield self.driver_type(connection=conn, statement_config=statement_config or self.statement_config)
267
165
 
268
166
  def provide_pool(self, *args: Any, **kwargs: Any) -> "ConnectionPool":
269
167
  """Provide pool instance.
@@ -284,211 +182,57 @@ class OracleSyncConfig(SyncDatabaseConfig[OracleSyncConnection, "ConnectionPool"
284
182
  Returns:
285
183
  Dictionary mapping type names to types.
286
184
  """
185
+
287
186
  namespace = super().get_signature_namespace()
288
- namespace.update({"OracleSyncConnection": OracleSyncConnection, "OracleAsyncConnection": OracleAsyncConnection})
187
+ namespace.update(
188
+ {
189
+ "OracleSyncConnection": OracleSyncConnection,
190
+ "OracleAsyncConnection": OracleAsyncConnection,
191
+ "OracleSyncCursor": OracleSyncCursor,
192
+ }
193
+ )
289
194
  return namespace
290
195
 
291
- @property
292
- def connection_config_dict(self) -> dict[str, Any]:
293
- """Return the connection configuration as a dict for Oracle operations.
294
-
295
- Returns all configuration parameters merged together.
296
- """
297
- # Gather non-None parameters from all fields (connection + pool)
298
- config = {
299
- field: getattr(self, field)
300
- for field in CONNECTION_FIELDS
301
- if getattr(self, field, None) is not None and getattr(self, field) is not Empty
302
- }
303
-
304
- # Merge extras parameters
305
- config.update(self.extras)
306
-
307
- return config
308
-
309
- @property
310
- def pool_config_dict(self) -> dict[str, Any]:
311
- """Return the pool configuration as a dict for Oracle operations.
312
-
313
- Returns all configuration parameters merged together.
314
- """
315
- # Gather non-None parameters from all fields (connection + pool)
316
- config = {
317
- field: getattr(self, field)
318
- for field in POOL_FIELDS
319
- if getattr(self, field, None) is not None and getattr(self, field) is not Empty
320
- }
321
-
322
- # Merge extras parameters
323
- config.update(self.extras)
324
-
325
- return config
326
-
327
196
 
328
197
  class OracleAsyncConfig(AsyncDatabaseConfig[OracleAsyncConnection, "AsyncConnectionPool", OracleAsyncDriver]):
329
198
  """Configuration for Oracle asynchronous database connections with direct field-based configuration."""
330
199
 
331
- is_async: ClassVar[bool] = True
332
- supports_connection_pooling: ClassVar[bool] = True
333
-
334
- connection_type: type[OracleAsyncConnection] = OracleAsyncConnection
335
- driver_type: type[OracleAsyncDriver] = OracleAsyncDriver
336
-
337
- # Parameter style support information
338
- supported_parameter_styles: ClassVar[tuple[str, ...]] = ("named_colon", "positional_colon")
339
- """OracleDB supports :name (named_colon) and :1 (positional_colon) parameter styles."""
340
-
341
- default_parameter_style: ClassVar[str] = "named_colon"
342
- """OracleDB's preferred parameter style is :name (named_colon)."""
200
+ connection_type: "ClassVar[type[OracleAsyncConnection]]" = OracleAsyncConnection
201
+ driver_type: ClassVar[type[OracleAsyncDriver]] = OracleAsyncDriver
343
202
 
344
203
  def __init__(
345
204
  self,
346
- statement_config: "Optional[SQLConfig]" = None,
347
- default_row_type: "type[DictRow]" = DictRow,
348
- # Connection parameters
349
- dsn: Optional[str] = None,
350
- user: Optional[str] = None,
351
- password: Optional[str] = None,
352
- host: Optional[str] = None,
353
- port: Optional[int] = None,
354
- service_name: Optional[str] = None,
355
- sid: Optional[str] = None,
356
- wallet_location: Optional[str] = None,
357
- wallet_password: Optional[str] = None,
358
- config_dir: Optional[str] = None,
359
- tcp_connect_timeout: Optional[float] = None,
360
- retry_count: Optional[int] = None,
361
- retry_delay: Optional[int] = None,
362
- mode: Optional["AuthMode"] = None,
363
- events: Optional[bool] = None,
364
- edition: Optional[str] = None,
365
- # Pool parameters
366
- min: Optional[int] = None,
367
- max: Optional[int] = None,
368
- increment: Optional[int] = None,
369
- threaded: Optional[bool] = None,
370
- getmode: Optional[int] = None,
371
- homogeneous: Optional[bool] = None,
372
- timeout: Optional[int] = None,
373
- wait_timeout: Optional[int] = None,
374
- max_lifetime_session: Optional[int] = None,
375
- session_callback: Optional["Callable[[Any, Any], None]"] = None,
376
- max_sessions_per_shard: Optional[int] = None,
377
- soda_metadata_cache: Optional[bool] = None,
378
- ping_interval: Optional[int] = None,
379
- pool_instance: Optional["AsyncConnectionPool"] = None,
380
- **kwargs: Any,
205
+ *,
206
+ pool_config: "Optional[Union[OraclePoolParams, dict[str, Any]]]" = None,
207
+ pool_instance: "Optional[AsyncConnectionPool]" = None,
208
+ statement_config: "Optional[StatementConfig]" = None,
209
+ migration_config: Optional[dict[str, Any]] = None,
381
210
  ) -> None:
382
211
  """Initialize Oracle asynchronous configuration.
383
212
 
384
213
  Args:
214
+ pool_config: Pool configuration parameters
215
+ pool_instance: Existing pool instance to use
385
216
  statement_config: Default SQL statement configuration
386
- default_row_type: Default row type for results
387
- dsn: Connection string for the database
388
- user: Username for database authentication
389
- password: Password for database authentication
390
- host: Database server hostname
391
- port: Database server port number
392
- service_name: Oracle service name
393
- sid: Oracle System ID (SID)
394
- wallet_location: Location of Oracle Wallet
395
- wallet_password: Password for accessing Oracle Wallet
396
- config_dir: Directory containing Oracle configuration files
397
- tcp_connect_timeout: Timeout for establishing TCP connections
398
- retry_count: Number of attempts to connect
399
- retry_delay: Time in seconds between connection attempts
400
- mode: Session mode (SYSDBA, SYSOPER, etc.)
401
- events: If True, enables Oracle events for FAN and RLB
402
- edition: Edition name for edition-based redefinition
403
- min: Minimum number of connections in the pool
404
- max: Maximum number of connections in the pool
405
- increment: Number of connections to create when pool needs to grow
406
- threaded: Whether the pool should be threaded
407
- getmode: How connections are returned from the pool
408
- homogeneous: Whether all connections use the same credentials
409
- timeout: Time in seconds after which idle connections are closed
410
- wait_timeout: Time in seconds to wait for an available connection
411
- max_lifetime_session: Maximum time in seconds that a connection can remain in the pool
412
- session_callback: Callback function called when a connection is returned to the pool
413
- max_sessions_per_shard: Maximum number of sessions per shard
414
- soda_metadata_cache: Whether to enable SODA metadata caching
415
- ping_interval: Interval for pinging pooled connections
416
- pool_instance: Optional existing async connection pool instance
417
- **kwargs: Additional parameters (stored in extras)
418
- """
419
- # Store connection parameters as instance attributes
420
- self.dsn = dsn
421
- self.user = user
422
- self.password = password
423
- self.host = host
424
- self.port = port
425
- self.service_name = service_name
426
- self.sid = sid
427
- self.wallet_location = wallet_location
428
- self.wallet_password = wallet_password
429
- self.config_dir = config_dir
430
- self.tcp_connect_timeout = tcp_connect_timeout
431
- self.retry_count = retry_count
432
- self.retry_delay = retry_delay
433
- self.mode = mode
434
- self.events = events
435
- self.edition = edition
436
-
437
- # Store pool parameters as instance attributes
438
- self.min = min
439
- self.max = max
440
- self.increment = increment
441
- self.threaded = threaded
442
- self.getmode = getmode
443
- self.homogeneous = homogeneous
444
- self.timeout = timeout
445
- self.wait_timeout = wait_timeout
446
- self.max_lifetime_session = max_lifetime_session
447
- self.session_callback = session_callback
448
- self.max_sessions_per_shard = max_sessions_per_shard
449
- self.soda_metadata_cache = soda_metadata_cache
450
- self.ping_interval = ping_interval
451
-
452
- self.extras = kwargs or {}
453
-
454
- # Store other config
455
- self.statement_config = statement_config or SQLConfig()
456
- self.default_row_type = default_row_type
457
-
458
- super().__init__()
459
-
460
- @property
461
- def connection_config_dict(self) -> dict[str, Any]:
462
- """Return the connection configuration as a dict for Oracle async operations.
463
-
464
- Returns all configuration parameters merged together.
465
- """
466
- # Gather non-None parameters
467
- config = {field: getattr(self, field) for field in CONNECTION_FIELDS if getattr(self, field, None) is not None}
468
-
469
- # Merge extras parameters
470
- config.update(self.extras)
471
-
472
- return config
473
-
474
- @property
475
- def pool_config_dict(self) -> dict[str, Any]:
476
- """Return the connection configuration as a dict for Oracle async operations.
477
-
478
- Returns all configuration parameters merged together.
217
+ migration_config: Migration configuration
479
218
  """
480
- # Gather non-None parameters
481
- config = {field: getattr(self, field) for field in POOL_FIELDS if getattr(self, field, None) is not None}
482
-
483
- # Merge extras parameters
484
- config.update(self.extras)
485
-
486
- return config
219
+ # Store the pool config as a dict and extract/merge extras
220
+ processed_pool_config: dict[str, Any] = dict(pool_config) if pool_config else {}
221
+ if "extra" in processed_pool_config:
222
+ extras = processed_pool_config.pop("extra")
223
+ processed_pool_config.update(extras)
224
+
225
+ super().__init__(
226
+ pool_config=processed_pool_config,
227
+ pool_instance=pool_instance,
228
+ migration_config=migration_config,
229
+ statement_config=statement_config or oracledb_statement_config,
230
+ )
487
231
 
488
232
  async def _create_pool(self) -> "AsyncConnectionPool":
489
233
  """Create the actual async connection pool."""
490
234
 
491
- return oracledb.create_pool_async(**self.pool_config_dict)
235
+ return oracledb.create_pool_async(**dict(self.pool_config))
492
236
 
493
237
  async def _close_pool(self) -> None:
494
238
  """Close the actual async connection pool."""
@@ -506,7 +250,7 @@ class OracleAsyncConfig(AsyncDatabaseConfig[OracleAsyncConnection, "AsyncConnect
506
250
  return cast("OracleAsyncConnection", await self.pool_instance.acquire())
507
251
 
508
252
  @asynccontextmanager
509
- async def provide_connection(self, *args: Any, **kwargs: Any) -> AsyncGenerator[OracleAsyncConnection, None]:
253
+ async def provide_connection(self, *args: Any, **kwargs: Any) -> "AsyncGenerator[OracleAsyncConnection, None]":
510
254
  """Provide an async connection context manager.
511
255
 
512
256
  Args:
@@ -525,29 +269,21 @@ class OracleAsyncConfig(AsyncDatabaseConfig[OracleAsyncConnection, "AsyncConnect
525
269
  await self.pool_instance.release(conn)
526
270
 
527
271
  @asynccontextmanager
528
- async def provide_session(self, *args: Any, **kwargs: Any) -> AsyncGenerator[OracleAsyncDriver, None]:
272
+ async def provide_session(
273
+ self, *args: Any, statement_config: "Optional[StatementConfig]" = None, **kwargs: Any
274
+ ) -> "AsyncGenerator[OracleAsyncDriver, None]":
529
275
  """Provide an async driver session context manager.
530
276
 
531
277
  Args:
532
278
  *args: Additional arguments.
279
+ statement_config: Optional statement configuration override.
533
280
  **kwargs: Additional keyword arguments.
534
281
 
535
282
  Yields:
536
283
  An OracleAsyncDriver instance.
537
284
  """
538
285
  async with self.provide_connection(*args, **kwargs) as conn:
539
- statement_config = self.statement_config
540
- # Inject parameter style info if not already set
541
- if statement_config.allowed_parameter_styles is None:
542
- from dataclasses import replace
543
-
544
- statement_config = replace(
545
- statement_config,
546
- allowed_parameter_styles=self.supported_parameter_styles,
547
- default_parameter_style=self.default_parameter_style,
548
- )
549
- driver = self.driver_type(connection=conn, config=statement_config)
550
- yield driver
286
+ yield self.driver_type(connection=conn, statement_config=statement_config or self.statement_config)
551
287
 
552
288
  async def provide_pool(self, *args: Any, **kwargs: Any) -> "AsyncConnectionPool":
553
289
  """Provide async pool instance.
@@ -568,6 +304,14 @@ class OracleAsyncConfig(AsyncDatabaseConfig[OracleAsyncConnection, "AsyncConnect
568
304
  Returns:
569
305
  Dictionary mapping type names to types.
570
306
  """
307
+
571
308
  namespace = super().get_signature_namespace()
572
- namespace.update({"OracleSyncConnection": OracleSyncConnection, "OracleAsyncConnection": OracleAsyncConnection})
309
+ namespace.update(
310
+ {
311
+ "OracleSyncConnection": OracleSyncConnection,
312
+ "OracleAsyncConnection": OracleAsyncConnection,
313
+ "OracleSyncCursor": OracleSyncCursor,
314
+ "OracleAsyncCursor": OracleAsyncCursor,
315
+ }
316
+ )
573
317
  return namespace