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
sqlspec/_typing.py CHANGED
@@ -1,8 +1,10 @@
1
+ # ruff: noqa: RUF100, PLR0913, A002, DOC201, PLR6301
1
2
  """This is a simple wrapper around a few important classes in each library.
2
3
 
3
4
  This is used to ensure compatibility when one or more of the libraries are installed.
4
5
  """
5
6
 
7
+ from collections.abc import Iterable, Mapping
6
8
  from enum import Enum
7
9
  from typing import (
8
10
  Any,
@@ -96,7 +98,7 @@ except ImportError:
96
98
 
97
99
  def validate_python(
98
100
  self,
99
- object: Any, # noqa: A002
101
+ object: Any,
100
102
  /,
101
103
  *,
102
104
  strict: "Optional[bool]" = None,
@@ -127,10 +129,7 @@ try:
127
129
  except ImportError:
128
130
  import enum
129
131
  from collections.abc import Iterable
130
- from typing import TYPE_CHECKING, Callable, Optional, Union
131
-
132
- if TYPE_CHECKING:
133
- from collections.abc import Iterable
132
+ from typing import Callable, Optional, Union
134
133
 
135
134
  @dataclass_transform()
136
135
  @runtime_checkable
@@ -174,7 +173,6 @@ except ImportError:
174
173
  """Placeholder init"""
175
174
 
176
175
  def create_instance(self, **kwargs: Any) -> "T":
177
- """Placeholder implementation"""
178
176
  return cast("T", kwargs)
179
177
 
180
178
  def update_instance(self, instance: "T", **kwargs: Any) -> "T":
@@ -198,11 +196,46 @@ EmptyType = Union[Literal[EmptyEnum.EMPTY], UnsetType]
198
196
  Empty: Final = EmptyEnum.EMPTY
199
197
 
200
198
 
199
+ try:
200
+ from pyarrow import Table as ArrowTable
201
+
202
+ PYARROW_INSTALLED = True
203
+ except ImportError:
204
+
205
+ @runtime_checkable
206
+ class ArrowTable(Protocol): # type: ignore[no-redef]
207
+ """Placeholder Implementation"""
208
+
209
+ def to_batches(self, batch_size: int) -> Any: ...
210
+ def num_rows(self) -> int: ...
211
+ def num_columns(self) -> int: ...
212
+ def to_pydict(self) -> dict[str, Any]: ...
213
+ def to_string(self) -> str: ...
214
+ def from_arrays(
215
+ self,
216
+ arrays: list[Any],
217
+ names: "Optional[list[str]]" = None,
218
+ schema: "Optional[Any]" = None,
219
+ metadata: "Optional[Mapping[str, Any]]" = None,
220
+ ) -> Any: ...
221
+ def from_pydict(
222
+ self,
223
+ mapping: dict[str, Any],
224
+ schema: "Optional[Any]" = None,
225
+ metadata: "Optional[Mapping[str, Any]]" = None,
226
+ ) -> Any: ...
227
+ def from_batches(self, batches: Iterable[Any], schema: Optional[Any] = None) -> Any: ...
228
+
229
+ PYARROW_INSTALLED = False # pyright: ignore[reportConstantRedefinition]
230
+
231
+
201
232
  __all__ = (
202
233
  "LITESTAR_INSTALLED",
203
234
  "MSGSPEC_INSTALLED",
235
+ "PYARROW_INSTALLED",
204
236
  "PYDANTIC_INSTALLED",
205
237
  "UNSET",
238
+ "ArrowTable",
206
239
  "BaseModel",
207
240
  "DTOData",
208
241
  "DataclassProtocol",
@@ -1,7 +1,7 @@
1
- from sqlspec.adapters.adbc.config import Adbc
1
+ from sqlspec.adapters.adbc.config import AdbcConfig
2
2
  from sqlspec.adapters.adbc.driver import AdbcDriver
3
3
 
4
4
  __all__ = (
5
- "Adbc",
5
+ "AdbcConfig",
6
6
  "AdbcDriver",
7
7
  )
@@ -14,11 +14,11 @@ if TYPE_CHECKING:
14
14
  from collections.abc import Generator
15
15
 
16
16
 
17
- __all__ = ("Adbc",)
17
+ __all__ = ("AdbcConfig",)
18
18
 
19
19
 
20
20
  @dataclass
21
- class Adbc(NoPoolSyncConfig["Connection", "AdbcDriver"]):
21
+ class AdbcConfig(NoPoolSyncConfig["Connection", "AdbcDriver"]):
22
22
  """Configuration for ADBC connections.
23
23
 
24
24
  This class provides configuration options for ADBC database connections using the
@@ -55,17 +55,41 @@ class Adbc(NoPoolSyncConfig["Connection", "AdbcDriver"]):
55
55
  """
56
56
 
57
57
  if isinstance(self.driver_name, str):
58
- if self.driver_name != "adbc_driver_sqlite.dbapi.connect" and "sqlite" in self.driver_name:
58
+ if self.driver_name != "adbc_driver_sqlite.dbapi.connect" and self.driver_name in {
59
+ "sqlite",
60
+ "sqlite3",
61
+ "adbc_driver_sqlite",
62
+ }:
59
63
  self.driver_name = "adbc_driver_sqlite.dbapi.connect"
60
- elif self.driver_name != "adbc_driver_duckdb.dbapi.connect" and "duckdb" in self.driver_name:
64
+ elif self.driver_name != "adbc_driver_duckdb.dbapi.connect" and self.driver_name in {
65
+ "duckdb",
66
+ "adbc_driver_duckdb",
67
+ }:
61
68
  self.driver_name = "adbc_driver_duckdb.dbapi.connect"
62
- elif self.driver_name != "adbc_driver_postgresql.dbapi.connect" and "postgres" in self.driver_name:
69
+ elif self.driver_name != "adbc_driver_postgresql.dbapi.connect" and self.driver_name in {
70
+ "postgres",
71
+ "adbc_driver_postgresql",
72
+ "postgresql",
73
+ "pg",
74
+ }:
63
75
  self.driver_name = "adbc_driver_postgresql.dbapi.connect"
64
- elif self.driver_name != "adbc_driver_snowflake.dbapi.connect" and "snowflake" in self.driver_name:
76
+ elif self.driver_name != "adbc_driver_snowflake.dbapi.connect" and self.driver_name in {
77
+ "snowflake",
78
+ "adbc_driver_snowflake",
79
+ "sf",
80
+ }:
65
81
  self.driver_name = "adbc_driver_snowflake.dbapi.connect"
66
- elif self.driver_name != "adbc_driver_bigquery.dbapi.connect" and "bigquery" in self.driver_name:
82
+ elif self.driver_name != "adbc_driver_bigquery.dbapi.connect" and self.driver_name in {
83
+ "bigquery",
84
+ "adbc_driver_bigquery",
85
+ "bq",
86
+ }:
67
87
  self.driver_name = "adbc_driver_bigquery.dbapi.connect"
68
- elif self.driver_name != "adbc_driver_flightsql.dbapi.connect" and "flightsql" in self.driver_name:
88
+ elif self.driver_name != "adbc_driver_flightsql.dbapi.connect" and self.driver_name in {
89
+ "flightsql",
90
+ "adbc_driver_flightsql",
91
+ "grpc",
92
+ }:
69
93
  self.driver_name = "adbc_driver_flightsql.dbapi.connect"
70
94
  return self.driver_name
71
95
 
@@ -153,11 +177,10 @@ class Adbc(NoPoolSyncConfig["Connection", "AdbcDriver"]):
153
177
  """
154
178
  try:
155
179
  connect_func = self._get_connect_func()
156
- _config = self.connection_config_dict
157
- return connect_func(**_config)
180
+ return connect_func(**self.connection_config_dict)
158
181
  except Exception as e:
159
182
  # Include driver name in error message for better context
160
- driver_name = self.driver_name if isinstance(self.driver_name, str) else "Unknown/Derived"
183
+ driver_name = self.driver_name if isinstance(self.driver_name, str) else "Unknown/Missing"
161
184
  # Use the potentially modified driver_path from _get_connect_func if available,
162
185
  # otherwise fallback to self.driver_name for the error message.
163
186
  # This requires _get_connect_func to potentially return the used path or store it.