sqlspec 0.8.0__py3-none-any.whl → 0.9.1__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 (45) hide show
  1. sqlspec/_typing.py +39 -6
  2. sqlspec/adapters/adbc/__init__.py +2 -2
  3. sqlspec/adapters/adbc/config.py +34 -11
  4. sqlspec/adapters/adbc/driver.py +302 -111
  5. sqlspec/adapters/aiosqlite/__init__.py +2 -2
  6. sqlspec/adapters/aiosqlite/config.py +2 -2
  7. sqlspec/adapters/aiosqlite/driver.py +164 -42
  8. sqlspec/adapters/asyncmy/__init__.py +3 -3
  9. sqlspec/adapters/asyncmy/config.py +11 -12
  10. sqlspec/adapters/asyncmy/driver.py +161 -37
  11. sqlspec/adapters/asyncpg/__init__.py +5 -5
  12. sqlspec/adapters/asyncpg/config.py +17 -19
  13. sqlspec/adapters/asyncpg/driver.py +386 -96
  14. sqlspec/adapters/duckdb/__init__.py +2 -2
  15. sqlspec/adapters/duckdb/config.py +2 -2
  16. sqlspec/adapters/duckdb/driver.py +190 -60
  17. sqlspec/adapters/oracledb/__init__.py +8 -8
  18. sqlspec/adapters/oracledb/config/__init__.py +6 -6
  19. sqlspec/adapters/oracledb/config/_asyncio.py +9 -10
  20. sqlspec/adapters/oracledb/config/_sync.py +8 -9
  21. sqlspec/adapters/oracledb/driver.py +384 -45
  22. sqlspec/adapters/psqlpy/__init__.py +0 -0
  23. sqlspec/adapters/psqlpy/config.py +250 -0
  24. sqlspec/adapters/psqlpy/driver.py +481 -0
  25. sqlspec/adapters/psycopg/__init__.py +10 -5
  26. sqlspec/adapters/psycopg/config/__init__.py +6 -6
  27. sqlspec/adapters/psycopg/config/_async.py +12 -12
  28. sqlspec/adapters/psycopg/config/_sync.py +13 -13
  29. sqlspec/adapters/psycopg/driver.py +432 -222
  30. sqlspec/adapters/sqlite/__init__.py +2 -2
  31. sqlspec/adapters/sqlite/config.py +2 -2
  32. sqlspec/adapters/sqlite/driver.py +176 -72
  33. sqlspec/base.py +687 -161
  34. sqlspec/exceptions.py +30 -0
  35. sqlspec/extensions/litestar/config.py +6 -0
  36. sqlspec/extensions/litestar/handlers.py +25 -0
  37. sqlspec/extensions/litestar/plugin.py +8 -1
  38. sqlspec/statement.py +373 -0
  39. sqlspec/typing.py +10 -1
  40. {sqlspec-0.8.0.dist-info → sqlspec-0.9.1.dist-info}/METADATA +144 -2
  41. sqlspec-0.9.1.dist-info/RECORD +61 -0
  42. sqlspec-0.8.0.dist-info/RECORD +0 -57
  43. {sqlspec-0.8.0.dist-info → sqlspec-0.9.1.dist-info}/WHEEL +0 -0
  44. {sqlspec-0.8.0.dist-info → sqlspec-0.9.1.dist-info}/licenses/LICENSE +0 -0
  45. {sqlspec-0.8.0.dist-info → sqlspec-0.9.1.dist-info}/licenses/NOTICE +0 -0
@@ -1,22 +1,31 @@
1
1
  from contextlib import asynccontextmanager, contextmanager
2
- from typing import TYPE_CHECKING, Any, Optional, Union, cast
2
+ from typing import TYPE_CHECKING, Any, Optional, Union, cast, overload
3
3
 
4
- from sqlspec.base import AsyncDriverAdapterProtocol, SyncDriverAdapterProtocol, T
4
+ from sqlspec.base import (
5
+ AsyncArrowBulkOperationsMixin,
6
+ AsyncDriverAdapterProtocol,
7
+ SyncArrowBulkOperationsMixin,
8
+ SyncDriverAdapterProtocol,
9
+ T,
10
+ )
11
+ from sqlspec.typing import ArrowTable, StatementParameterType
5
12
 
6
13
  if TYPE_CHECKING:
7
- from collections.abc import AsyncGenerator, Generator
14
+ from collections.abc import AsyncGenerator, Generator, Sequence
8
15
 
9
16
  from oracledb import AsyncConnection, AsyncCursor, Connection, Cursor
10
17
 
11
- from sqlspec.typing import ModelDTOT, StatementParameterType
18
+ # Conditionally import ArrowTable for type checking
19
+ from sqlspec.typing import ModelDTOT
12
20
 
13
21
  __all__ = ("OracleAsyncDriver", "OracleSyncDriver")
14
22
 
15
23
 
16
- class OracleSyncDriver(SyncDriverAdapterProtocol["Connection"]):
24
+ class OracleSyncDriver(SyncArrowBulkOperationsMixin["Connection"], SyncDriverAdapterProtocol["Connection"]):
17
25
  """Oracle Sync Driver Adapter."""
18
26
 
19
27
  connection: "Connection"
28
+ dialect: str = "oracle"
20
29
 
21
30
  def __init__(self, connection: "Connection") -> None:
22
31
  self.connection = connection
@@ -30,21 +39,53 @@ class OracleSyncDriver(SyncDriverAdapterProtocol["Connection"]):
30
39
  finally:
31
40
  cursor.close()
32
41
 
42
+ # --- Public API Methods --- #
43
+ @overload
33
44
  def select(
34
45
  self,
35
46
  sql: str,
36
47
  parameters: "Optional[StatementParameterType]" = None,
37
48
  /,
49
+ *,
50
+ connection: "Optional[Connection]" = None,
51
+ schema_type: None = None,
52
+ **kwargs: Any,
53
+ ) -> "Sequence[dict[str, Any]]": ...
54
+ @overload
55
+ def select(
56
+ self,
57
+ sql: str,
58
+ parameters: "Optional[StatementParameterType]" = None,
59
+ /,
60
+ *,
61
+ connection: "Optional[Connection]" = None,
62
+ schema_type: "type[ModelDTOT]",
63
+ **kwargs: Any,
64
+ ) -> "Sequence[ModelDTOT]": ...
65
+ def select(
66
+ self,
67
+ sql: str,
68
+ parameters: "Optional[StatementParameterType]" = None,
69
+ /,
70
+ *,
38
71
  connection: "Optional[Connection]" = None,
39
72
  schema_type: "Optional[type[ModelDTOT]]" = None,
40
- ) -> "list[Union[ModelDTOT, dict[str, Any]]]":
73
+ **kwargs: Any,
74
+ ) -> "Sequence[Union[ModelDTOT, dict[str, Any]]]":
41
75
  """Fetch data from the database.
42
76
 
77
+ Args:
78
+ sql: The SQL query string.
79
+ parameters: The parameters for the query (dict, tuple, list, or None).
80
+ connection: Optional connection override.
81
+ schema_type: Optional schema class for the result.
82
+ **kwargs: Additional keyword arguments to merge with parameters if parameters is a dict.
83
+
43
84
  Returns:
44
85
  List of row data as either model instances or dictionaries.
45
86
  """
46
87
  connection = self._connection(connection)
47
- sql, parameters = self._process_sql_params(sql, parameters)
88
+ sql, parameters = self._process_sql_params(sql, parameters, **kwargs)
48
89
  with self._with_cursor(connection) as cursor:
49
90
  cursor.execute(sql, parameters) # pyright: ignore[reportUnknownMemberType]
50
91
  results = cursor.fetchall() # pyright: ignore[reportUnknownMemberType, reportUnknownVariableType]
@@ -58,21 +99,52 @@ class OracleSyncDriver(SyncDriverAdapterProtocol["Connection"]):
58
99
 
59
100
  return [dict(zip(column_names, row)) for row in results] # pyright: ignore
60
101
 
102
+ @overload
61
103
  def select_one(
62
104
  self,
63
105
  sql: str,
64
106
  parameters: "Optional[StatementParameterType]" = None,
65
107
  /,
108
+ *,
109
+ connection: "Optional[Connection]" = None,
110
+ schema_type: None = None,
111
+ **kwargs: Any,
112
+ ) -> "dict[str, Any]": ...
113
+ @overload
114
+ def select_one(
115
+ self,
116
+ sql: str,
117
+ parameters: "Optional[StatementParameterType]" = None,
118
+ /,
119
+ *,
120
+ connection: "Optional[Connection]" = None,
121
+ schema_type: "type[ModelDTOT]",
122
+ **kwargs: Any,
123
+ ) -> "ModelDTOT": ...
124
+ def select_one(
125
+ self,
126
+ sql: str,
127
+ parameters: "Optional[StatementParameterType]" = None,
128
+ /,
129
+ *,
66
130
  connection: "Optional[Connection]" = None,
67
131
  schema_type: "Optional[type[ModelDTOT]]" = None,
132
+ **kwargs: Any,
68
133
  ) -> "Union[ModelDTOT, dict[str, Any]]":
69
134
  """Fetch one row from the database.
70
135
 
136
+ Args:
137
+ sql: The SQL query string.
138
+ parameters: The parameters for the query (dict, tuple, list, or None).
139
+ connection: Optional connection override.
140
+ schema_type: Optional schema class for the result.
141
+ **kwargs: Additional keyword arguments to merge with parameters if parameters is a dict.
142
+
71
143
  Returns:
72
144
  The first row of the query results.
73
145
  """
74
146
  connection = self._connection(connection)
75
- sql, parameters = self._process_sql_params(sql, parameters)
147
+ sql, parameters = self._process_sql_params(sql, parameters, **kwargs)
76
148
 
77
149
  with self._with_cursor(connection) as cursor:
78
150
  cursor.execute(sql, parameters) # pyright: ignore[reportUnknownMemberType]
@@ -87,13 +159,37 @@ class OracleSyncDriver(SyncDriverAdapterProtocol["Connection"]):
87
159
  # Always return dictionaries
88
160
  return dict(zip(column_names, result)) # pyright: ignore[reportUnknownArgumentType,reportUnknownVariableType]
89
161
 
162
+ @overload
163
+ def select_one_or_none(
164
+ self,
165
+ sql: str,
166
+ parameters: "Optional[StatementParameterType]" = None,
167
+ /,
168
+ *,
169
+ connection: "Optional[Connection]" = None,
170
+ schema_type: None = None,
171
+ **kwargs: Any,
172
+ ) -> "Optional[dict[str, Any]]": ...
173
+ @overload
174
+ def select_one_or_none(
175
+ self,
176
+ sql: str,
177
+ parameters: "Optional[StatementParameterType]" = None,
178
+ /,
179
+ *,
180
+ connection: "Optional[Connection]" = None,
181
+ schema_type: "type[ModelDTOT]",
182
+ **kwargs: Any,
183
+ ) -> "Optional[ModelDTOT]": ...
90
184
  def select_one_or_none(
91
185
  self,
92
186
  sql: str,
93
187
  parameters: "Optional[StatementParameterType]" = None,
94
188
  /,
189
+ *,
95
190
  connection: "Optional[Connection]" = None,
96
191
  schema_type: "Optional[type[ModelDTOT]]" = None,
192
+ **kwargs: Any,
97
193
  ) -> "Optional[Union[ModelDTOT, dict[str, Any]]]":
98
194
  """Fetch one row from the database.
99
195
 
@@ -101,7 +197,7 @@ class OracleSyncDriver(SyncDriverAdapterProtocol["Connection"]):
101
197
  The first row of the query results.
102
198
  """
103
199
  connection = self._connection(connection)
104
- sql, parameters = self._process_sql_params(sql, parameters)
200
+ sql, parameters = self._process_sql_params(sql, parameters, **kwargs)
105
201
 
106
202
  with self._with_cursor(connection) as cursor:
107
203
  cursor.execute(sql, parameters) # pyright: ignore[reportUnknownMemberType]
@@ -118,13 +214,37 @@ class OracleSyncDriver(SyncDriverAdapterProtocol["Connection"]):
118
214
  # Always return dictionaries
119
215
  return dict(zip(column_names, result)) # pyright: ignore[reportUnknownArgumentType,reportUnknownVariableType]
120
216
 
217
+ @overload
121
218
  def select_value(
122
219
  self,
123
220
  sql: str,
124
221
  parameters: "Optional[StatementParameterType]" = None,
125
222
  /,
223
+ *,
224
+ connection: "Optional[Connection]" = None,
225
+ schema_type: None = None,
226
+ **kwargs: Any,
227
+ ) -> "Any": ...
228
+ @overload
229
+ def select_value(
230
+ self,
231
+ sql: str,
232
+ parameters: "Optional[StatementParameterType]" = None,
233
+ /,
234
+ *,
235
+ connection: "Optional[Connection]" = None,
236
+ schema_type: "type[T]",
237
+ **kwargs: Any,
238
+ ) -> "T": ...
239
+ def select_value(
240
+ self,
241
+ sql: str,
242
+ parameters: "Optional[StatementParameterType]" = None,
243
+ /,
244
+ *,
126
245
  connection: "Optional[Connection]" = None,
127
246
  schema_type: "Optional[type[T]]" = None,
247
+ **kwargs: Any,
128
248
  ) -> "Union[T, Any]":
129
249
  """Fetch a single value from the database.
130
250
 
@@ -132,7 +252,7 @@ class OracleSyncDriver(SyncDriverAdapterProtocol["Connection"]):
132
252
  The first value from the first row of results, or None if no results.
133
253
  """
134
254
  connection = self._connection(connection)
135
- sql, parameters = self._process_sql_params(sql, parameters)
255
+ sql, parameters = self._process_sql_params(sql, parameters, **kwargs)
136
256
 
137
257
  with self._with_cursor(connection) as cursor:
138
258
  cursor.execute(sql, parameters) # pyright: ignore[reportUnknownMemberType]
@@ -143,13 +263,37 @@ class OracleSyncDriver(SyncDriverAdapterProtocol["Connection"]):
143
263
  return result[0] # pyright: ignore[reportUnknownArgumentType]
144
264
  return schema_type(result[0]) # type: ignore[call-arg]
145
265
 
266
+ @overload
267
+ def select_value_or_none(
268
+ self,
269
+ sql: str,
270
+ parameters: "Optional[StatementParameterType]" = None,
271
+ /,
272
+ *,
273
+ connection: "Optional[Connection]" = None,
274
+ schema_type: None = None,
275
+ **kwargs: Any,
276
+ ) -> "Optional[Any]": ...
277
+ @overload
146
278
  def select_value_or_none(
147
279
  self,
148
280
  sql: str,
149
281
  parameters: "Optional[StatementParameterType]" = None,
150
282
  /,
283
+ *,
284
+ connection: "Optional[Connection]" = None,
285
+ schema_type: "type[T]",
286
+ **kwargs: Any,
287
+ ) -> "Optional[T]": ...
288
+ def select_value_or_none(
289
+ self,
290
+ sql: str,
291
+ parameters: "Optional[StatementParameterType]" = None,
292
+ /,
293
+ *,
151
294
  connection: "Optional[Connection]" = None,
152
295
  schema_type: "Optional[type[T]]" = None,
296
+ **kwargs: Any,
153
297
  ) -> "Optional[Union[T, Any]]":
154
298
  """Fetch a single value from the database.
155
299
 
@@ -157,7 +301,7 @@ class OracleSyncDriver(SyncDriverAdapterProtocol["Connection"]):
157
301
  The first value from the first row of results, or None if no results.
158
302
  """
159
303
  connection = self._connection(connection)
160
- sql, parameters = self._process_sql_params(sql, parameters)
304
+ sql, parameters = self._process_sql_params(sql, parameters, **kwargs)
161
305
 
162
306
  with self._with_cursor(connection) as cursor:
163
307
  cursor.execute(sql, parameters) # pyright: ignore[reportUnknownMemberType]
@@ -175,7 +319,9 @@ class OracleSyncDriver(SyncDriverAdapterProtocol["Connection"]):
175
319
  sql: str,
176
320
  parameters: "Optional[StatementParameterType]" = None,
177
321
  /,
322
+ *,
178
323
  connection: "Optional[Connection]" = None,
324
+ **kwargs: Any,
179
325
  ) -> int:
180
326
  """Insert, update, or delete data from the database.
181
327
 
@@ -183,19 +329,43 @@ class OracleSyncDriver(SyncDriverAdapterProtocol["Connection"]):
183
329
  Row count affected by the operation.
184
330
  """
185
331
  connection = self._connection(connection)
186
- sql, parameters = self._process_sql_params(sql, parameters)
332
+ sql, parameters = self._process_sql_params(sql, parameters, **kwargs)
187
333
 
188
334
  with self._with_cursor(connection) as cursor:
189
335
  cursor.execute(sql, parameters) # pyright: ignore[reportUnknownMemberType]
190
336
  return cursor.rowcount # pyright: ignore[reportUnknownMemberType]
191
337
 
338
+ @overload
339
+ def insert_update_delete_returning(
340
+ self,
341
+ sql: str,
342
+ parameters: "Optional[StatementParameterType]" = None,
343
+ /,
344
+ *,
345
+ connection: "Optional[Connection]" = None,
346
+ schema_type: None = None,
347
+ **kwargs: Any,
348
+ ) -> "dict[str, Any]": ...
349
+ @overload
192
350
  def insert_update_delete_returning(
193
351
  self,
194
352
  sql: str,
195
353
  parameters: "Optional[StatementParameterType]" = None,
196
354
  /,
355
+ *,
356
+ connection: "Optional[Connection]" = None,
357
+ schema_type: "type[ModelDTOT]",
358
+ **kwargs: Any,
359
+ ) -> "ModelDTOT": ...
360
+ def insert_update_delete_returning(
361
+ self,
362
+ sql: str,
363
+ parameters: "Optional[StatementParameterType]" = None,
364
+ /,
365
+ *,
197
366
  connection: "Optional[Connection]" = None,
198
367
  schema_type: "Optional[type[ModelDTOT]]" = None,
368
+ **kwargs: Any,
199
369
  ) -> "Optional[Union[dict[str, Any], ModelDTOT]]":
200
370
  """Insert, update, or delete data from the database and return result.
201
371
 
@@ -203,7 +373,7 @@ class OracleSyncDriver(SyncDriverAdapterProtocol["Connection"]):
203
373
  The first row of results.
204
374
  """
205
375
  connection = self._connection(connection)
206
- sql, parameters = self._process_sql_params(sql, parameters)
376
+ sql, parameters = self._process_sql_params(sql, parameters, **kwargs)
207
377
 
208
378
  with self._with_cursor(connection) as cursor:
209
379
  cursor.execute(sql, parameters) # pyright: ignore[reportUnknownMemberType]
@@ -225,7 +395,9 @@ class OracleSyncDriver(SyncDriverAdapterProtocol["Connection"]):
225
395
  sql: str,
226
396
  parameters: "Optional[StatementParameterType]" = None,
227
397
  /,
398
+ *,
228
399
  connection: "Optional[Connection]" = None,
400
+ **kwargs: Any,
229
401
  ) -> str:
230
402
  """Execute a script.
231
403
 
@@ -233,17 +405,40 @@ class OracleSyncDriver(SyncDriverAdapterProtocol["Connection"]):
233
405
  Status message for the operation.
234
406
  """
235
407
  connection = self._connection(connection)
236
- sql, parameters = self._process_sql_params(sql, parameters)
408
+ sql, parameters = self._process_sql_params(sql, parameters, **kwargs)
237
409
 
238
410
  with self._with_cursor(connection) as cursor:
239
411
  cursor.execute(sql, parameters) # pyright: ignore[reportUnknownMemberType]
240
412
  return str(cursor.rowcount) # pyright: ignore[reportUnknownMemberType]
241
413
 
414
+ def select_arrow( # pyright: ignore[reportUnknownParameterType]
415
+ self,
416
+ sql: str,
417
+ parameters: "Optional[StatementParameterType]" = None,
418
+ /,
419
+ *,
420
+ connection: "Optional[Connection]" = None,
421
+ **kwargs: Any,
422
+ ) -> "ArrowTable": # pyright: ignore[reportUnknownVariableType]
423
+ """Execute a SQL query and return results as an Apache Arrow Table.
424
+
425
+ Returns:
426
+ An Apache Arrow Table containing the query results.
427
+ """
428
+
429
+ connection = self._connection(connection)
430
+ sql, parameters = self._process_sql_params(sql, parameters, **kwargs)
431
+ results = connection.fetch_df_all(sql, parameters)
432
+ return cast("ArrowTable", ArrowTable.from_arrays(arrays=results.column_arrays(), names=results.column_names())) # pyright: ignore
242
433
 
243
- class OracleAsyncDriver(AsyncDriverAdapterProtocol["AsyncConnection"]):
434
+
435
+ class OracleAsyncDriver(
436
+ AsyncArrowBulkOperationsMixin["AsyncConnection"], AsyncDriverAdapterProtocol["AsyncConnection"]
437
+ ):
244
438
  """Oracle Async Driver Adapter."""
245
439
 
246
440
  connection: "AsyncConnection"
441
+ dialect: str = "oracle"
247
442
 
248
443
  def __init__(self, connection: "AsyncConnection") -> None:
249
444
  self.connection = connection
@@ -257,21 +452,46 @@ class OracleAsyncDriver(AsyncDriverAdapterProtocol["AsyncConnection"]):
257
452
  finally:
258
453
  cursor.close()
259
454
 
455
+ # --- Public API Methods --- #
456
+ @overload
260
457
  async def select(
261
458
  self,
262
459
  sql: str,
263
460
  parameters: "Optional[StatementParameterType]" = None,
264
461
  /,
462
+ *,
463
+ connection: "Optional[AsyncConnection]" = None,
464
+ schema_type: None = None,
465
+ **kwargs: Any,
466
+ ) -> "Sequence[dict[str, Any]]": ...
467
+ @overload
468
+ async def select(
469
+ self,
470
+ sql: str,
471
+ parameters: "Optional[StatementParameterType]" = None,
472
+ /,
473
+ *,
474
+ connection: "Optional[AsyncConnection]" = None,
475
+ schema_type: "type[ModelDTOT]",
476
+ **kwargs: Any,
477
+ ) -> "Sequence[ModelDTOT]": ...
478
+ async def select(
479
+ self,
480
+ sql: str,
481
+ parameters: "Optional[StatementParameterType]" = None,
482
+ /,
483
+ *,
265
484
  connection: "Optional[AsyncConnection]" = None,
266
485
  schema_type: "Optional[type[ModelDTOT]]" = None,
267
- ) -> "list[Union[ModelDTOT, dict[str, Any]]]":
486
+ **kwargs: Any,
487
+ ) -> "Sequence[Union[ModelDTOT, dict[str, Any]]]":
268
488
  """Fetch data from the database.
269
489
 
270
490
  Returns:
271
491
  List of row data as either model instances or dictionaries.
272
492
  """
273
493
  connection = self._connection(connection)
274
- sql, parameters = self._process_sql_params(sql, parameters)
494
+ sql, parameters = self._process_sql_params(sql, parameters, **kwargs)
275
495
 
276
496
  async with self._with_cursor(connection) as cursor:
277
497
  await cursor.execute(sql, parameters) # pyright: ignore[reportUnknownMemberType]
@@ -286,13 +506,37 @@ class OracleAsyncDriver(AsyncDriverAdapterProtocol["AsyncConnection"]):
286
506
 
287
507
  return [dict(zip(column_names, row)) for row in results] # pyright: ignore
288
508
 
509
+ @overload
510
+ async def select_one(
511
+ self,
512
+ sql: str,
513
+ parameters: "Optional[StatementParameterType]" = None,
514
+ /,
515
+ *,
516
+ connection: "Optional[AsyncConnection]" = None,
517
+ schema_type: None = None,
518
+ **kwargs: Any,
519
+ ) -> "dict[str, Any]": ...
520
+ @overload
289
521
  async def select_one(
290
522
  self,
291
523
  sql: str,
292
524
  parameters: "Optional[StatementParameterType]" = None,
293
525
  /,
526
+ *,
527
+ connection: "Optional[AsyncConnection]" = None,
528
+ schema_type: "type[ModelDTOT]",
529
+ **kwargs: Any,
530
+ ) -> "ModelDTOT": ...
531
+ async def select_one(
532
+ self,
533
+ sql: str,
534
+ parameters: "Optional[StatementParameterType]" = None,
535
+ /,
536
+ *,
294
537
  connection: "Optional[AsyncConnection]" = None,
295
538
  schema_type: "Optional[type[ModelDTOT]]" = None,
539
+ **kwargs: Any,
296
540
  ) -> "Union[ModelDTOT, dict[str, Any]]":
297
541
  """Fetch one row from the database.
298
542
 
@@ -300,7 +544,7 @@ class OracleAsyncDriver(AsyncDriverAdapterProtocol["AsyncConnection"]):
300
544
  The first row of the query results.
301
545
  """
302
546
  connection = self._connection(connection)
303
- sql, parameters = self._process_sql_params(sql, parameters)
547
+ sql, parameters = self._process_sql_params(sql, parameters, **kwargs)
304
548
 
305
549
  async with self._with_cursor(connection) as cursor:
306
550
  await cursor.execute(sql, parameters) # pyright: ignore[reportUnknownMemberType]
@@ -314,13 +558,37 @@ class OracleAsyncDriver(AsyncDriverAdapterProtocol["AsyncConnection"]):
314
558
  # Always return dictionaries
315
559
  return dict(zip(column_names, result)) # pyright: ignore[reportUnknownArgumentType,reportUnknownVariableType]
316
560
 
561
+ @overload
562
+ async def select_one_or_none(
563
+ self,
564
+ sql: str,
565
+ parameters: "Optional[StatementParameterType]" = None,
566
+ /,
567
+ *,
568
+ connection: "Optional[AsyncConnection]" = None,
569
+ schema_type: None = None,
570
+ **kwargs: Any,
571
+ ) -> "Optional[dict[str, Any]]": ...
572
+ @overload
317
573
  async def select_one_or_none(
318
574
  self,
319
575
  sql: str,
320
576
  parameters: "Optional[StatementParameterType]" = None,
321
577
  /,
578
+ *,
579
+ connection: "Optional[AsyncConnection]" = None,
580
+ schema_type: "type[ModelDTOT]",
581
+ **kwargs: Any,
582
+ ) -> "Optional[ModelDTOT]": ...
583
+ async def select_one_or_none(
584
+ self,
585
+ sql: str,
586
+ parameters: "Optional[StatementParameterType]" = None,
587
+ /,
588
+ *,
322
589
  connection: "Optional[AsyncConnection]" = None,
323
590
  schema_type: "Optional[type[ModelDTOT]]" = None,
591
+ **kwargs: Any,
324
592
  ) -> "Optional[Union[ModelDTOT, dict[str, Any]]]":
325
593
  """Fetch one row from the database.
326
594
 
@@ -328,7 +596,7 @@ class OracleAsyncDriver(AsyncDriverAdapterProtocol["AsyncConnection"]):
328
596
  The first row of the query results.
329
597
  """
330
598
  connection = self._connection(connection)
331
- sql, parameters = self._process_sql_params(sql, parameters)
599
+ sql, parameters = self._process_sql_params(sql, parameters, **kwargs)
332
600
 
333
601
  async with self._with_cursor(connection) as cursor:
334
602
  await cursor.execute(sql, parameters) # pyright: ignore[reportUnknownMemberType]
@@ -345,13 +613,37 @@ class OracleAsyncDriver(AsyncDriverAdapterProtocol["AsyncConnection"]):
345
613
  # Always return dictionaries
346
614
  return dict(zip(column_names, result)) # pyright: ignore[reportUnknownArgumentType,reportUnknownVariableType]
347
615
 
616
+ @overload
617
+ async def select_value(
618
+ self,
619
+ sql: str,
620
+ parameters: "Optional[StatementParameterType]" = None,
621
+ /,
622
+ *,
623
+ connection: "Optional[AsyncConnection]" = None,
624
+ schema_type: None = None,
625
+ **kwargs: Any,
626
+ ) -> "Any": ...
627
+ @overload
628
+ async def select_value(
629
+ self,
630
+ sql: str,
631
+ parameters: "Optional[StatementParameterType]" = None,
632
+ /,
633
+ *,
634
+ connection: "Optional[AsyncConnection]" = None,
635
+ schema_type: "type[T]",
636
+ **kwargs: Any,
637
+ ) -> "T": ...
348
638
  async def select_value(
349
639
  self,
350
640
  sql: str,
351
641
  parameters: "Optional[StatementParameterType]" = None,
352
642
  /,
643
+ *,
353
644
  connection: "Optional[AsyncConnection]" = None,
354
645
  schema_type: "Optional[type[T]]" = None,
646
+ **kwargs: Any,
355
647
  ) -> "Union[T, Any]":
356
648
  """Fetch a single value from the database.
357
649
 
@@ -359,7 +651,7 @@ class OracleAsyncDriver(AsyncDriverAdapterProtocol["AsyncConnection"]):
359
651
  The first value from the first row of results, or None if no results.
360
652
  """
361
653
  connection = self._connection(connection)
362
- sql, parameters = self._process_sql_params(sql, parameters)
654
+ sql, parameters = self._process_sql_params(sql, parameters, **kwargs)
363
655
 
364
656
  async with self._with_cursor(connection) as cursor:
365
657
  await cursor.execute(sql, parameters) # pyright: ignore[reportUnknownMemberType]
@@ -370,13 +662,37 @@ class OracleAsyncDriver(AsyncDriverAdapterProtocol["AsyncConnection"]):
370
662
  return result[0] # pyright: ignore[reportUnknownArgumentType]
371
663
  return schema_type(result[0]) # type: ignore[call-arg]
372
664
 
665
+ @overload
373
666
  async def select_value_or_none(
374
667
  self,
375
668
  sql: str,
376
669
  parameters: "Optional[StatementParameterType]" = None,
377
670
  /,
671
+ *,
672
+ connection: "Optional[AsyncConnection]" = None,
673
+ schema_type: None = None,
674
+ **kwargs: Any,
675
+ ) -> "Optional[Any]": ...
676
+ @overload
677
+ async def select_value_or_none(
678
+ self,
679
+ sql: str,
680
+ parameters: "Optional[StatementParameterType]" = None,
681
+ /,
682
+ *,
683
+ connection: "Optional[AsyncConnection]" = None,
684
+ schema_type: "type[T]",
685
+ **kwargs: Any,
686
+ ) -> "Optional[T]": ...
687
+ async def select_value_or_none(
688
+ self,
689
+ sql: str,
690
+ parameters: "Optional[StatementParameterType]" = None,
691
+ /,
692
+ *,
378
693
  connection: "Optional[AsyncConnection]" = None,
379
694
  schema_type: "Optional[type[T]]" = None,
695
+ **kwargs: Any,
380
696
  ) -> "Optional[Union[T, Any]]":
381
697
  """Fetch a single value from the database.
382
698
 
@@ -384,7 +700,7 @@ class OracleAsyncDriver(AsyncDriverAdapterProtocol["AsyncConnection"]):
384
700
  The first value from the first row of results, or None if no results.
385
701
  """
386
702
  connection = self._connection(connection)
387
- sql, parameters = self._process_sql_params(sql, parameters)
703
+ sql, parameters = self._process_sql_params(sql, parameters, **kwargs)
388
704
 
389
705
  async with self._with_cursor(connection) as cursor:
390
706
  await cursor.execute(sql, parameters) # pyright: ignore[reportUnknownMemberType]
@@ -402,7 +718,9 @@ class OracleAsyncDriver(AsyncDriverAdapterProtocol["AsyncConnection"]):
402
718
  sql: str,
403
719
  parameters: "Optional[StatementParameterType]" = None,
404
720
  /,
721
+ *,
405
722
  connection: "Optional[AsyncConnection]" = None,
723
+ **kwargs: Any,
406
724
  ) -> int:
407
725
  """Insert, update, or delete data from the database.
408
726
 
@@ -410,19 +728,43 @@ class OracleAsyncDriver(AsyncDriverAdapterProtocol["AsyncConnection"]):
410
728
  Row count affected by the operation.
411
729
  """
412
730
  connection = self._connection(connection)
413
- sql, parameters = self._process_sql_params(sql, parameters)
731
+ sql, parameters = self._process_sql_params(sql, parameters, **kwargs)
414
732
 
415
733
  async with self._with_cursor(connection) as cursor:
416
734
  await cursor.execute(sql, parameters) # pyright: ignore[reportUnknownMemberType]
417
735
  return cursor.rowcount # pyright: ignore[reportUnknownMemberType]
418
736
 
737
+ @overload
738
+ async def insert_update_delete_returning(
739
+ self,
740
+ sql: str,
741
+ parameters: "Optional[StatementParameterType]" = None,
742
+ /,
743
+ *,
744
+ connection: "Optional[AsyncConnection]" = None,
745
+ schema_type: None = None,
746
+ **kwargs: Any,
747
+ ) -> "dict[str, Any]": ...
748
+ @overload
749
+ async def insert_update_delete_returning(
750
+ self,
751
+ sql: str,
752
+ parameters: "Optional[StatementParameterType]" = None,
753
+ /,
754
+ *,
755
+ connection: "Optional[AsyncConnection]" = None,
756
+ schema_type: "type[ModelDTOT]",
757
+ **kwargs: Any,
758
+ ) -> "ModelDTOT": ...
419
759
  async def insert_update_delete_returning(
420
760
  self,
421
761
  sql: str,
422
762
  parameters: "Optional[StatementParameterType]" = None,
423
763
  /,
764
+ *,
424
765
  connection: "Optional[AsyncConnection]" = None,
425
766
  schema_type: "Optional[type[ModelDTOT]]" = None,
767
+ **kwargs: Any,
426
768
  ) -> "Optional[Union[dict[str, Any], ModelDTOT]]":
427
769
  """Insert, update, or delete data from the database and return result.
428
770
 
@@ -430,7 +772,7 @@ class OracleAsyncDriver(AsyncDriverAdapterProtocol["AsyncConnection"]):
430
772
  The first row of results.
431
773
  """
432
774
  connection = self._connection(connection)
433
- sql, parameters = self._process_sql_params(sql, parameters)
775
+ sql, parameters = self._process_sql_params(sql, parameters, **kwargs)
434
776
 
435
777
  async with self._with_cursor(connection) as cursor:
436
778
  await cursor.execute(sql, parameters) # pyright: ignore[reportUnknownMemberType]
@@ -452,7 +794,9 @@ class OracleAsyncDriver(AsyncDriverAdapterProtocol["AsyncConnection"]):
452
794
  sql: str,
453
795
  parameters: "Optional[StatementParameterType]" = None,
454
796
  /,
797
+ *,
455
798
  connection: "Optional[AsyncConnection]" = None,
799
+ **kwargs: Any,
456
800
  ) -> str:
457
801
  """Execute a script.
458
802
 
@@ -460,39 +804,34 @@ class OracleAsyncDriver(AsyncDriverAdapterProtocol["AsyncConnection"]):
460
804
  Status message for the operation.
461
805
  """
462
806
  connection = self._connection(connection)
463
- sql, parameters = self._process_sql_params(sql, parameters)
807
+ sql, parameters = self._process_sql_params(sql, parameters, **kwargs)
464
808
 
465
809
  async with self._with_cursor(connection) as cursor:
466
810
  await cursor.execute(sql, parameters) # pyright: ignore[reportUnknownMemberType]
467
811
  return str(cursor.rowcount) # pyright: ignore[reportUnknownMemberType]
468
812
 
469
- async def execute_script_returning(
813
+ async def select_arrow( # pyright: ignore[reportUnknownParameterType]
470
814
  self,
471
815
  sql: str,
472
816
  parameters: "Optional[StatementParameterType]" = None,
473
817
  /,
818
+ *,
474
819
  connection: "Optional[AsyncConnection]" = None,
475
- schema_type: "Optional[type[ModelDTOT]]" = None,
476
- ) -> "Optional[Union[dict[str, Any], ModelDTOT]]":
477
- """Execute a script and return result.
820
+ **kwargs: Any,
821
+ ) -> "ArrowTable": # pyright: ignore[reportUnknownVariableType]
822
+ """Execute a SQL query asynchronously and return results as an Apache Arrow Table.
823
+
824
+ Args:
825
+ sql: The SQL query string.
826
+ parameters: Parameters for the query.
827
+ connection: Optional connection override.
828
+ **kwargs: Additional keyword arguments to merge with parameters if parameters is a dict.
478
829
 
479
830
  Returns:
480
- The first row of results.
831
+ An Apache Arrow Table containing the query results.
481
832
  """
482
- connection = self._connection(connection)
483
- sql, parameters = self._process_sql_params(sql, parameters)
484
-
485
- async with self._with_cursor(connection) as cursor:
486
- await cursor.execute(sql, parameters) # pyright: ignore[reportUnknownMemberType]
487
- result = await cursor.fetchone() # pyright: ignore[reportUnknownMemberType, reportUnknownVariableType]
488
833
 
489
- if result is None:
490
- return None
491
-
492
- # Get column names
493
- column_names = [col[0] for col in cursor.description or []] # pyright: ignore[reportUnknownMemberType,reportUnknownVariableType]
494
-
495
- if schema_type is not None:
496
- return cast("ModelDTOT", schema_type(**dict(zip(column_names, result)))) # pyright: ignore[reportUnknownArgumentType]
497
- # Always return dictionaries
498
- return dict(zip(column_names, result)) # pyright: ignore[reportUnknownArgumentType,reportUnknownVariableType]
834
+ connection = self._connection(connection)
835
+ sql, parameters = self._process_sql_params(sql, parameters, **kwargs)
836
+ results = await connection.fetch_df_all(sql, parameters)
837
+ return ArrowTable.from_arrays(arrays=results.column_arrays(), names=results.column_names()) # pyright: ignore