sqlspec 0.9.1__py3-none-any.whl → 0.10.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 (48) hide show
  1. sqlspec/__init__.py +2 -1
  2. sqlspec/_typing.py +24 -32
  3. sqlspec/adapters/adbc/__init__.py +2 -1
  4. sqlspec/adapters/adbc/config.py +7 -13
  5. sqlspec/adapters/adbc/driver.py +37 -30
  6. sqlspec/adapters/aiosqlite/__init__.py +2 -1
  7. sqlspec/adapters/aiosqlite/config.py +10 -12
  8. sqlspec/adapters/aiosqlite/driver.py +36 -31
  9. sqlspec/adapters/asyncmy/__init__.py +2 -1
  10. sqlspec/adapters/asyncmy/driver.py +34 -31
  11. sqlspec/adapters/asyncpg/config.py +1 -3
  12. sqlspec/adapters/asyncpg/driver.py +7 -3
  13. sqlspec/adapters/bigquery/__init__.py +4 -0
  14. sqlspec/adapters/bigquery/config/__init__.py +3 -0
  15. sqlspec/adapters/bigquery/config/_common.py +40 -0
  16. sqlspec/adapters/bigquery/config/_sync.py +87 -0
  17. sqlspec/adapters/bigquery/driver.py +701 -0
  18. sqlspec/adapters/duckdb/__init__.py +2 -1
  19. sqlspec/adapters/duckdb/config.py +17 -18
  20. sqlspec/adapters/duckdb/driver.py +38 -30
  21. sqlspec/adapters/oracledb/__init__.py +8 -1
  22. sqlspec/adapters/oracledb/config/_asyncio.py +7 -8
  23. sqlspec/adapters/oracledb/config/_sync.py +6 -7
  24. sqlspec/adapters/oracledb/driver.py +65 -62
  25. sqlspec/adapters/psqlpy/__init__.py +9 -0
  26. sqlspec/adapters/psqlpy/config.py +5 -5
  27. sqlspec/adapters/psqlpy/driver.py +34 -28
  28. sqlspec/adapters/psycopg/__init__.py +8 -1
  29. sqlspec/adapters/psycopg/config/__init__.py +10 -0
  30. sqlspec/adapters/psycopg/config/_async.py +6 -7
  31. sqlspec/adapters/psycopg/config/_sync.py +7 -8
  32. sqlspec/adapters/psycopg/driver.py +63 -53
  33. sqlspec/adapters/sqlite/__init__.py +2 -1
  34. sqlspec/adapters/sqlite/config.py +12 -11
  35. sqlspec/adapters/sqlite/driver.py +36 -29
  36. sqlspec/base.py +1 -66
  37. sqlspec/exceptions.py +9 -0
  38. sqlspec/extensions/litestar/config.py +3 -11
  39. sqlspec/extensions/litestar/handlers.py +2 -1
  40. sqlspec/extensions/litestar/plugin.py +4 -2
  41. sqlspec/mixins.py +156 -0
  42. sqlspec/typing.py +19 -1
  43. {sqlspec-0.9.1.dist-info → sqlspec-0.10.1.dist-info}/METADATA +8 -3
  44. sqlspec-0.10.1.dist-info/RECORD +67 -0
  45. sqlspec-0.9.1.dist-info/RECORD +0 -61
  46. {sqlspec-0.9.1.dist-info → sqlspec-0.10.1.dist-info}/WHEEL +0 -0
  47. {sqlspec-0.9.1.dist-info → sqlspec-0.10.1.dist-info}/licenses/LICENSE +0 -0
  48. {sqlspec-0.9.1.dist-info → sqlspec-0.10.1.dist-info}/licenses/NOTICE +0 -0
@@ -5,22 +5,25 @@ import logging
5
5
  import re
6
6
  from typing import TYPE_CHECKING, Any, Optional, Union, cast, overload
7
7
 
8
+ from psqlpy import Connection, QueryResult
8
9
  from psqlpy.exceptions import RustPSQLDriverPyBaseError
9
10
 
10
- from sqlspec.base import AsyncDriverAdapterProtocol, T
11
+ from sqlspec.base import AsyncDriverAdapterProtocol
11
12
  from sqlspec.exceptions import SQLParsingError
13
+ from sqlspec.mixins import SQLTranslatorMixin
12
14
  from sqlspec.statement import PARAM_REGEX, SQLStatement
13
15
 
14
16
  if TYPE_CHECKING:
15
17
  from collections.abc import Sequence
16
18
 
17
- from psqlpy import Connection, QueryResult
19
+ from psqlpy import QueryResult
18
20
 
19
- from sqlspec.typing import ModelDTOT, StatementParameterType
21
+ from sqlspec.typing import ModelDTOT, StatementParameterType, T
20
22
 
21
- __all__ = ("PsqlpyDriver",)
23
+ __all__ = ("PsqlpyConnection", "PsqlpyDriver")
22
24
 
23
25
 
26
+ PsqlpyConnection = Connection
24
27
  # Regex to find '?' placeholders, skipping those inside quotes or SQL comments
25
28
  QMARK_REGEX = re.compile(
26
29
  r"""(?P<dquote>"[^"]*") | # Double-quoted strings
@@ -33,13 +36,16 @@ QMARK_REGEX = re.compile(
33
36
  logger = logging.getLogger("sqlspec")
34
37
 
35
38
 
36
- class PsqlpyDriver(AsyncDriverAdapterProtocol["Connection"]):
39
+ class PsqlpyDriver(
40
+ SQLTranslatorMixin["PsqlpyConnection"],
41
+ AsyncDriverAdapterProtocol["PsqlpyConnection"],
42
+ ):
37
43
  """Psqlpy Postgres Driver Adapter."""
38
44
 
39
- connection: "Connection"
45
+ connection: "PsqlpyConnection"
40
46
  dialect: str = "postgres"
41
47
 
42
- def __init__(self, connection: "Connection") -> None:
48
+ def __init__(self, connection: "PsqlpyConnection") -> None:
43
49
  self.connection = connection
44
50
 
45
51
  def _process_sql_params(
@@ -175,7 +181,7 @@ class PsqlpyDriver(AsyncDriverAdapterProtocol["Connection"]):
175
181
  parameters: "Optional[StatementParameterType]" = None,
176
182
  /,
177
183
  *,
178
- connection: "Optional[Connection]" = None,
184
+ connection: "Optional[PsqlpyConnection]" = None,
179
185
  schema_type: None = None,
180
186
  **kwargs: Any,
181
187
  ) -> "Sequence[dict[str, Any]]": ...
@@ -186,7 +192,7 @@ class PsqlpyDriver(AsyncDriverAdapterProtocol["Connection"]):
186
192
  parameters: "Optional[StatementParameterType]" = None,
187
193
  /,
188
194
  *,
189
- connection: "Optional[Connection]" = None,
195
+ connection: "Optional[PsqlpyConnection]" = None,
190
196
  schema_type: "type[ModelDTOT]",
191
197
  **kwargs: Any,
192
198
  ) -> "Sequence[ModelDTOT]": ...
@@ -196,7 +202,7 @@ class PsqlpyDriver(AsyncDriverAdapterProtocol["Connection"]):
196
202
  parameters: Optional["StatementParameterType"] = None,
197
203
  /,
198
204
  *,
199
- connection: Optional["Connection"] = None,
205
+ connection: Optional["PsqlpyConnection"] = None,
200
206
  schema_type: "Optional[type[ModelDTOT]]" = None,
201
207
  **kwargs: Any,
202
208
  ) -> "Sequence[Union[ModelDTOT, dict[str, Any]]]":
@@ -217,7 +223,7 @@ class PsqlpyDriver(AsyncDriverAdapterProtocol["Connection"]):
217
223
  parameters: "Optional[StatementParameterType]" = None,
218
224
  /,
219
225
  *,
220
- connection: "Optional[Connection]" = None,
226
+ connection: "Optional[PsqlpyConnection]" = None,
221
227
  schema_type: None = None,
222
228
  **kwargs: Any,
223
229
  ) -> "dict[str, Any]": ...
@@ -228,7 +234,7 @@ class PsqlpyDriver(AsyncDriverAdapterProtocol["Connection"]):
228
234
  parameters: "Optional[StatementParameterType]" = None,
229
235
  /,
230
236
  *,
231
- connection: "Optional[Connection]" = None,
237
+ connection: "Optional[PsqlpyConnection]" = None,
232
238
  schema_type: "type[ModelDTOT]",
233
239
  **kwargs: Any,
234
240
  ) -> "ModelDTOT": ...
@@ -238,7 +244,7 @@ class PsqlpyDriver(AsyncDriverAdapterProtocol["Connection"]):
238
244
  parameters: Optional["StatementParameterType"] = None,
239
245
  /,
240
246
  *,
241
- connection: Optional["Connection"] = None,
247
+ connection: Optional["PsqlpyConnection"] = None,
242
248
  schema_type: "Optional[type[ModelDTOT]]" = None,
243
249
  **kwargs: Any,
244
250
  ) -> "Union[ModelDTOT, dict[str, Any]]":
@@ -260,7 +266,7 @@ class PsqlpyDriver(AsyncDriverAdapterProtocol["Connection"]):
260
266
  parameters: "Optional[StatementParameterType]" = None,
261
267
  /,
262
268
  *,
263
- connection: "Optional[Connection]" = None,
269
+ connection: "Optional[PsqlpyConnection]" = None,
264
270
  schema_type: None = None,
265
271
  **kwargs: Any,
266
272
  ) -> "Optional[dict[str, Any]]": ...
@@ -271,7 +277,7 @@ class PsqlpyDriver(AsyncDriverAdapterProtocol["Connection"]):
271
277
  parameters: "Optional[StatementParameterType]" = None,
272
278
  /,
273
279
  *,
274
- connection: "Optional[Connection]" = None,
280
+ connection: "Optional[PsqlpyConnection]" = None,
275
281
  schema_type: "type[ModelDTOT]",
276
282
  **kwargs: Any,
277
283
  ) -> "Optional[ModelDTOT]": ...
@@ -281,7 +287,7 @@ class PsqlpyDriver(AsyncDriverAdapterProtocol["Connection"]):
281
287
  parameters: Optional["StatementParameterType"] = None,
282
288
  /,
283
289
  *,
284
- connection: Optional["Connection"] = None,
290
+ connection: Optional["PsqlpyConnection"] = None,
285
291
  schema_type: "Optional[type[ModelDTOT]]" = None,
286
292
  **kwargs: Any,
287
293
  ) -> "Optional[Union[ModelDTOT, dict[str, Any]]]":
@@ -307,7 +313,7 @@ class PsqlpyDriver(AsyncDriverAdapterProtocol["Connection"]):
307
313
  parameters: "Optional[StatementParameterType]" = None,
308
314
  /,
309
315
  *,
310
- connection: "Optional[Connection]" = None,
316
+ connection: "Optional[PsqlpyConnection]" = None,
311
317
  schema_type: None = None,
312
318
  **kwargs: Any,
313
319
  ) -> "Any": ...
@@ -318,7 +324,7 @@ class PsqlpyDriver(AsyncDriverAdapterProtocol["Connection"]):
318
324
  parameters: "Optional[StatementParameterType]" = None,
319
325
  /,
320
326
  *,
321
- connection: "Optional[Connection]" = None,
327
+ connection: "Optional[PsqlpyConnection]" = None,
322
328
  schema_type: "type[T]",
323
329
  **kwargs: Any,
324
330
  ) -> "T": ...
@@ -328,7 +334,7 @@ class PsqlpyDriver(AsyncDriverAdapterProtocol["Connection"]):
328
334
  parameters: "Optional[StatementParameterType]" = None,
329
335
  /,
330
336
  *,
331
- connection: "Optional[Connection]" = None,
337
+ connection: "Optional[PsqlpyConnection]" = None,
332
338
  schema_type: "Optional[type[T]]" = None,
333
339
  **kwargs: Any,
334
340
  ) -> "Union[T, Any]":
@@ -349,7 +355,7 @@ class PsqlpyDriver(AsyncDriverAdapterProtocol["Connection"]):
349
355
  parameters: "Optional[StatementParameterType]" = None,
350
356
  /,
351
357
  *,
352
- connection: "Optional[Connection]" = None,
358
+ connection: "Optional[PsqlpyConnection]" = None,
353
359
  schema_type: None = None,
354
360
  **kwargs: Any,
355
361
  ) -> "Optional[Any]": ...
@@ -360,7 +366,7 @@ class PsqlpyDriver(AsyncDriverAdapterProtocol["Connection"]):
360
366
  parameters: "Optional[StatementParameterType]" = None,
361
367
  /,
362
368
  *,
363
- connection: "Optional[Connection]" = None,
369
+ connection: "Optional[PsqlpyConnection]" = None,
364
370
  schema_type: "type[T]",
365
371
  **kwargs: Any,
366
372
  ) -> "Optional[T]": ...
@@ -370,7 +376,7 @@ class PsqlpyDriver(AsyncDriverAdapterProtocol["Connection"]):
370
376
  parameters: "Optional[StatementParameterType]" = None,
371
377
  /,
372
378
  *,
373
- connection: "Optional[Connection]" = None,
379
+ connection: "Optional[PsqlpyConnection]" = None,
374
380
  schema_type: "Optional[type[T]]" = None,
375
381
  **kwargs: Any,
376
382
  ) -> "Optional[Union[T, Any]]":
@@ -394,7 +400,7 @@ class PsqlpyDriver(AsyncDriverAdapterProtocol["Connection"]):
394
400
  parameters: Optional["StatementParameterType"] = None,
395
401
  /,
396
402
  *,
397
- connection: Optional["Connection"] = None,
403
+ connection: Optional["PsqlpyConnection"] = None,
398
404
  **kwargs: Any,
399
405
  ) -> int:
400
406
  connection = self._connection(connection)
@@ -413,7 +419,7 @@ class PsqlpyDriver(AsyncDriverAdapterProtocol["Connection"]):
413
419
  parameters: "Optional[StatementParameterType]" = None,
414
420
  /,
415
421
  *,
416
- connection: "Optional[Connection]" = None,
422
+ connection: "Optional[PsqlpyConnection]" = None,
417
423
  schema_type: None = None,
418
424
  **kwargs: Any,
419
425
  ) -> "dict[str, Any]": ...
@@ -424,7 +430,7 @@ class PsqlpyDriver(AsyncDriverAdapterProtocol["Connection"]):
424
430
  parameters: "Optional[StatementParameterType]" = None,
425
431
  /,
426
432
  *,
427
- connection: "Optional[Connection]" = None,
433
+ connection: "Optional[PsqlpyConnection]" = None,
428
434
  schema_type: "type[ModelDTOT]",
429
435
  **kwargs: Any,
430
436
  ) -> "ModelDTOT": ...
@@ -434,7 +440,7 @@ class PsqlpyDriver(AsyncDriverAdapterProtocol["Connection"]):
434
440
  parameters: Optional["StatementParameterType"] = None,
435
441
  /,
436
442
  *,
437
- connection: Optional["Connection"] = None,
443
+ connection: Optional["PsqlpyConnection"] = None,
438
444
  schema_type: "Optional[type[ModelDTOT]]" = None,
439
445
  **kwargs: Any,
440
446
  ) -> "Optional[Union[dict[str, Any], ModelDTOT]]":
@@ -459,7 +465,7 @@ class PsqlpyDriver(AsyncDriverAdapterProtocol["Connection"]):
459
465
  parameters: Optional["StatementParameterType"] = None,
460
466
  /,
461
467
  *,
462
- connection: Optional["Connection"] = None,
468
+ connection: Optional["PsqlpyConnection"] = None,
463
469
  **kwargs: Any,
464
470
  ) -> str:
465
471
  connection = self._connection(connection)
@@ -469,7 +475,7 @@ class PsqlpyDriver(AsyncDriverAdapterProtocol["Connection"]):
469
475
  await connection.execute(sql, parameters=parameters)
470
476
  return sql
471
477
 
472
- def _connection(self, connection: Optional["Connection"] = None) -> "Connection":
478
+ def _connection(self, connection: Optional["PsqlpyConnection"] = None) -> "PsqlpyConnection":
473
479
  """Get the connection to use.
474
480
 
475
481
  Args:
@@ -4,13 +4,20 @@ from sqlspec.adapters.psycopg.config import (
4
4
  PsycopgSyncConfig,
5
5
  PsycopgSyncPoolConfig,
6
6
  )
7
- from sqlspec.adapters.psycopg.driver import PsycopgAsyncDriver, PsycopgSyncDriver
7
+ from sqlspec.adapters.psycopg.driver import (
8
+ PsycopgAsyncConnection,
9
+ PsycopgAsyncDriver,
10
+ PsycopgSyncConnection,
11
+ PsycopgSyncDriver,
12
+ )
8
13
 
9
14
  __all__ = (
10
15
  "PsycopgAsyncConfig",
16
+ "PsycopgAsyncConnection",
11
17
  "PsycopgAsyncDriver",
12
18
  "PsycopgAsyncPoolConfig",
13
19
  "PsycopgSyncConfig",
20
+ "PsycopgSyncConnection",
14
21
  "PsycopgSyncDriver",
15
22
  "PsycopgSyncPoolConfig",
16
23
  )
@@ -1,9 +1,19 @@
1
1
  from sqlspec.adapters.psycopg.config._async import PsycopgAsyncConfig, PsycopgAsyncPoolConfig
2
2
  from sqlspec.adapters.psycopg.config._sync import PsycopgSyncConfig, PsycopgSyncPoolConfig
3
+ from sqlspec.adapters.psycopg.driver import (
4
+ PsycopgAsyncConnection,
5
+ PsycopgAsyncDriver,
6
+ PsycopgSyncConnection,
7
+ PsycopgSyncDriver,
8
+ )
3
9
 
4
10
  __all__ = (
5
11
  "PsycopgAsyncConfig",
12
+ "PsycopgAsyncConnection",
13
+ "PsycopgAsyncDriver",
6
14
  "PsycopgAsyncPoolConfig",
7
15
  "PsycopgSyncConfig",
16
+ "PsycopgSyncConnection",
17
+ "PsycopgSyncDriver",
8
18
  "PsycopgSyncPoolConfig",
9
19
  )
@@ -2,11 +2,10 @@ from contextlib import asynccontextmanager
2
2
  from dataclasses import dataclass, field
3
3
  from typing import TYPE_CHECKING, Any, Optional
4
4
 
5
- from psycopg import AsyncConnection
6
5
  from psycopg_pool import AsyncConnectionPool
7
6
 
8
7
  from sqlspec.adapters.psycopg.config._common import PsycopgGenericPoolConfig
9
- from sqlspec.adapters.psycopg.driver import PsycopgAsyncDriver
8
+ from sqlspec.adapters.psycopg.driver import PsycopgAsyncConnection, PsycopgAsyncDriver
10
9
  from sqlspec.base import AsyncDatabaseConfig
11
10
  from sqlspec.exceptions import ImproperConfigurationError
12
11
  from sqlspec.typing import dataclass_to_dict
@@ -22,12 +21,12 @@ __all__ = (
22
21
 
23
22
 
24
23
  @dataclass
25
- class PsycopgAsyncPoolConfig(PsycopgGenericPoolConfig[AsyncConnection, AsyncConnectionPool]):
24
+ class PsycopgAsyncPoolConfig(PsycopgGenericPoolConfig[PsycopgAsyncConnection, AsyncConnectionPool]):
26
25
  """Async Psycopg Pool Config"""
27
26
 
28
27
 
29
28
  @dataclass
30
- class PsycopgAsyncConfig(AsyncDatabaseConfig[AsyncConnection, AsyncConnectionPool, PsycopgAsyncDriver]):
29
+ class PsycopgAsyncConfig(AsyncDatabaseConfig[PsycopgAsyncConnection, AsyncConnectionPool, PsycopgAsyncDriver]):
31
30
  """Async Psycopg database Configuration.
32
31
 
33
32
  This class provides the base configuration for Psycopg database connections, extending
@@ -41,7 +40,7 @@ class PsycopgAsyncConfig(AsyncDatabaseConfig[AsyncConnection, AsyncConnectionPoo
41
40
  """Psycopg Pool configuration"""
42
41
  pool_instance: "Optional[AsyncConnectionPool]" = None
43
42
  """Optional pool to use"""
44
- connection_type: "type[AsyncConnection]" = field(init=False, default_factory=lambda: AsyncConnection) # type: ignore[assignment]
43
+ connection_type: "type[PsycopgAsyncConnection]" = field(init=False, default_factory=lambda: PsycopgAsyncConnection) # type: ignore[assignment]
45
44
  """Type of the connection object"""
46
45
  driver_type: "type[PsycopgAsyncDriver]" = field(init=False, default_factory=lambda: PsycopgAsyncDriver) # type: ignore[type-abstract,unused-ignore]
47
46
  """Type of the driver object"""
@@ -93,7 +92,7 @@ class PsycopgAsyncConfig(AsyncDatabaseConfig[AsyncConnection, AsyncConnectionPoo
93
92
  msg = "'pool_config' methods can not be used when a 'pool_instance' is provided."
94
93
  raise ImproperConfigurationError(msg)
95
94
 
96
- async def create_connection(self) -> "AsyncConnection":
95
+ async def create_connection(self) -> "PsycopgAsyncConnection":
97
96
  """Create and return a new psycopg async connection from the pool.
98
97
 
99
98
  Returns:
@@ -143,7 +142,7 @@ class PsycopgAsyncConfig(AsyncDatabaseConfig[AsyncConnection, AsyncConnectionPoo
143
142
  return self.create_pool()
144
143
 
145
144
  @asynccontextmanager
146
- async def provide_connection(self, *args: "Any", **kwargs: "Any") -> "AsyncGenerator[AsyncConnection, None]":
145
+ async def provide_connection(self, *args: "Any", **kwargs: "Any") -> "AsyncGenerator[PsycopgAsyncConnection, None]":
147
146
  """Create and provide a database connection.
148
147
 
149
148
  Yields:
@@ -2,11 +2,10 @@ from contextlib import contextmanager
2
2
  from dataclasses import dataclass, field
3
3
  from typing import TYPE_CHECKING, Any, Optional
4
4
 
5
- from psycopg import Connection
6
5
  from psycopg_pool import ConnectionPool
7
6
 
8
7
  from sqlspec.adapters.psycopg.config._common import PsycopgGenericPoolConfig
9
- from sqlspec.adapters.psycopg.driver import PsycopgSyncDriver
8
+ from sqlspec.adapters.psycopg.driver import PsycopgSyncConnection, PsycopgSyncDriver
10
9
  from sqlspec.base import SyncDatabaseConfig
11
10
  from sqlspec.exceptions import ImproperConfigurationError
12
11
  from sqlspec.typing import dataclass_to_dict
@@ -22,12 +21,12 @@ __all__ = (
22
21
 
23
22
 
24
23
  @dataclass
25
- class PsycopgSyncPoolConfig(PsycopgGenericPoolConfig[Connection, ConnectionPool]):
24
+ class PsycopgSyncPoolConfig(PsycopgGenericPoolConfig[PsycopgSyncConnection, ConnectionPool]):
26
25
  """Sync Psycopg Pool Config"""
27
26
 
28
27
 
29
28
  @dataclass
30
- class PsycopgSyncConfig(SyncDatabaseConfig[Connection, ConnectionPool, PsycopgSyncDriver]):
29
+ class PsycopgSyncConfig(SyncDatabaseConfig[PsycopgSyncConnection, ConnectionPool, PsycopgSyncDriver]):
31
30
  """Sync Psycopg database Configuration.
32
31
  This class provides the base configuration for Psycopg database connections, extending
33
32
  the generic database configuration with Psycopg-specific settings.([1](https://www.psycopg.org/psycopg3/docs/api/connections.html))
@@ -40,7 +39,7 @@ class PsycopgSyncConfig(SyncDatabaseConfig[Connection, ConnectionPool, PsycopgSy
40
39
  """Psycopg Pool configuration"""
41
40
  pool_instance: "Optional[ConnectionPool]" = None
42
41
  """Optional pool to use"""
43
- connection_type: "type[Connection]" = field(init=False, default_factory=lambda: Connection) # type: ignore[assignment]
42
+ connection_type: "type[PsycopgSyncConnection]" = field(init=False, default_factory=lambda: PsycopgSyncConnection) # type: ignore[assignment]
44
43
  """Type of the connection object"""
45
44
  driver_type: "type[PsycopgSyncDriver]" = field(init=False, default_factory=lambda: PsycopgSyncDriver) # type: ignore[type-abstract,unused-ignore]
46
45
  """Type of the driver object"""
@@ -92,7 +91,7 @@ class PsycopgSyncConfig(SyncDatabaseConfig[Connection, ConnectionPool, PsycopgSy
92
91
  msg = "'pool_config' methods can not be used when a 'pool_instance' is provided."
93
92
  raise ImproperConfigurationError(msg)
94
93
 
95
- def create_connection(self) -> "Connection":
94
+ def create_connection(self) -> "PsycopgSyncConnection":
96
95
  """Create and return a new psycopg connection from the pool.
97
96
 
98
97
  Returns:
@@ -142,11 +141,11 @@ class PsycopgSyncConfig(SyncDatabaseConfig[Connection, ConnectionPool, PsycopgSy
142
141
  return self.create_pool()
143
142
 
144
143
  @contextmanager
145
- def provide_connection(self, *args: "Any", **kwargs: "Any") -> "Generator[Connection, None, None]":
144
+ def provide_connection(self, *args: "Any", **kwargs: "Any") -> "Generator[PsycopgSyncConnection, None, None]":
146
145
  """Create and provide a database connection.
147
146
 
148
147
  Yields:
149
- Connection: A database connection from the pool.
148
+ PsycopgSyncConnection: A database connection from the pool.
150
149
  """
151
150
  pool = self.provide_pool(*args, **kwargs)
152
151
  with pool, pool.connection() as connection: