sqlspec 0.16.1__cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.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 (148) hide show
  1. 51ff5a9eadfdefd49f98__mypyc.cpython-312-aarch64-linux-gnu.so +0 -0
  2. sqlspec/__init__.py +92 -0
  3. sqlspec/__main__.py +12 -0
  4. sqlspec/__metadata__.py +14 -0
  5. sqlspec/_serialization.py +77 -0
  6. sqlspec/_sql.py +1780 -0
  7. sqlspec/_typing.py +680 -0
  8. sqlspec/adapters/__init__.py +0 -0
  9. sqlspec/adapters/adbc/__init__.py +5 -0
  10. sqlspec/adapters/adbc/_types.py +12 -0
  11. sqlspec/adapters/adbc/config.py +361 -0
  12. sqlspec/adapters/adbc/driver.py +512 -0
  13. sqlspec/adapters/aiosqlite/__init__.py +19 -0
  14. sqlspec/adapters/aiosqlite/_types.py +13 -0
  15. sqlspec/adapters/aiosqlite/config.py +253 -0
  16. sqlspec/adapters/aiosqlite/driver.py +248 -0
  17. sqlspec/adapters/asyncmy/__init__.py +19 -0
  18. sqlspec/adapters/asyncmy/_types.py +12 -0
  19. sqlspec/adapters/asyncmy/config.py +180 -0
  20. sqlspec/adapters/asyncmy/driver.py +274 -0
  21. sqlspec/adapters/asyncpg/__init__.py +21 -0
  22. sqlspec/adapters/asyncpg/_types.py +17 -0
  23. sqlspec/adapters/asyncpg/config.py +229 -0
  24. sqlspec/adapters/asyncpg/driver.py +344 -0
  25. sqlspec/adapters/bigquery/__init__.py +18 -0
  26. sqlspec/adapters/bigquery/_types.py +12 -0
  27. sqlspec/adapters/bigquery/config.py +298 -0
  28. sqlspec/adapters/bigquery/driver.py +558 -0
  29. sqlspec/adapters/duckdb/__init__.py +22 -0
  30. sqlspec/adapters/duckdb/_types.py +12 -0
  31. sqlspec/adapters/duckdb/config.py +504 -0
  32. sqlspec/adapters/duckdb/driver.py +368 -0
  33. sqlspec/adapters/oracledb/__init__.py +32 -0
  34. sqlspec/adapters/oracledb/_types.py +14 -0
  35. sqlspec/adapters/oracledb/config.py +317 -0
  36. sqlspec/adapters/oracledb/driver.py +538 -0
  37. sqlspec/adapters/psqlpy/__init__.py +16 -0
  38. sqlspec/adapters/psqlpy/_types.py +11 -0
  39. sqlspec/adapters/psqlpy/config.py +214 -0
  40. sqlspec/adapters/psqlpy/driver.py +530 -0
  41. sqlspec/adapters/psycopg/__init__.py +32 -0
  42. sqlspec/adapters/psycopg/_types.py +17 -0
  43. sqlspec/adapters/psycopg/config.py +426 -0
  44. sqlspec/adapters/psycopg/driver.py +796 -0
  45. sqlspec/adapters/sqlite/__init__.py +15 -0
  46. sqlspec/adapters/sqlite/_types.py +11 -0
  47. sqlspec/adapters/sqlite/config.py +240 -0
  48. sqlspec/adapters/sqlite/driver.py +294 -0
  49. sqlspec/base.py +571 -0
  50. sqlspec/builder/__init__.py +62 -0
  51. sqlspec/builder/_base.py +473 -0
  52. sqlspec/builder/_column.py +320 -0
  53. sqlspec/builder/_ddl.py +1346 -0
  54. sqlspec/builder/_ddl_utils.py +103 -0
  55. sqlspec/builder/_delete.py +76 -0
  56. sqlspec/builder/_insert.py +256 -0
  57. sqlspec/builder/_merge.py +71 -0
  58. sqlspec/builder/_parsing_utils.py +140 -0
  59. sqlspec/builder/_select.py +170 -0
  60. sqlspec/builder/_update.py +188 -0
  61. sqlspec/builder/mixins/__init__.py +55 -0
  62. sqlspec/builder/mixins/_cte_and_set_ops.py +222 -0
  63. sqlspec/builder/mixins/_delete_operations.py +41 -0
  64. sqlspec/builder/mixins/_insert_operations.py +244 -0
  65. sqlspec/builder/mixins/_join_operations.py +122 -0
  66. sqlspec/builder/mixins/_merge_operations.py +476 -0
  67. sqlspec/builder/mixins/_order_limit_operations.py +135 -0
  68. sqlspec/builder/mixins/_pivot_operations.py +153 -0
  69. sqlspec/builder/mixins/_select_operations.py +603 -0
  70. sqlspec/builder/mixins/_update_operations.py +187 -0
  71. sqlspec/builder/mixins/_where_clause.py +621 -0
  72. sqlspec/cli.py +247 -0
  73. sqlspec/config.py +395 -0
  74. sqlspec/core/__init__.py +63 -0
  75. sqlspec/core/cache.cpython-312-aarch64-linux-gnu.so +0 -0
  76. sqlspec/core/cache.py +871 -0
  77. sqlspec/core/compiler.cpython-312-aarch64-linux-gnu.so +0 -0
  78. sqlspec/core/compiler.py +417 -0
  79. sqlspec/core/filters.cpython-312-aarch64-linux-gnu.so +0 -0
  80. sqlspec/core/filters.py +830 -0
  81. sqlspec/core/hashing.cpython-312-aarch64-linux-gnu.so +0 -0
  82. sqlspec/core/hashing.py +310 -0
  83. sqlspec/core/parameters.cpython-312-aarch64-linux-gnu.so +0 -0
  84. sqlspec/core/parameters.py +1237 -0
  85. sqlspec/core/result.cpython-312-aarch64-linux-gnu.so +0 -0
  86. sqlspec/core/result.py +677 -0
  87. sqlspec/core/splitter.cpython-312-aarch64-linux-gnu.so +0 -0
  88. sqlspec/core/splitter.py +819 -0
  89. sqlspec/core/statement.cpython-312-aarch64-linux-gnu.so +0 -0
  90. sqlspec/core/statement.py +676 -0
  91. sqlspec/driver/__init__.py +19 -0
  92. sqlspec/driver/_async.py +502 -0
  93. sqlspec/driver/_common.py +631 -0
  94. sqlspec/driver/_sync.py +503 -0
  95. sqlspec/driver/mixins/__init__.py +6 -0
  96. sqlspec/driver/mixins/_result_tools.py +193 -0
  97. sqlspec/driver/mixins/_sql_translator.py +86 -0
  98. sqlspec/exceptions.py +193 -0
  99. sqlspec/extensions/__init__.py +0 -0
  100. sqlspec/extensions/aiosql/__init__.py +10 -0
  101. sqlspec/extensions/aiosql/adapter.py +461 -0
  102. sqlspec/extensions/litestar/__init__.py +6 -0
  103. sqlspec/extensions/litestar/_utils.py +52 -0
  104. sqlspec/extensions/litestar/cli.py +48 -0
  105. sqlspec/extensions/litestar/config.py +92 -0
  106. sqlspec/extensions/litestar/handlers.py +260 -0
  107. sqlspec/extensions/litestar/plugin.py +145 -0
  108. sqlspec/extensions/litestar/providers.py +454 -0
  109. sqlspec/loader.cpython-312-aarch64-linux-gnu.so +0 -0
  110. sqlspec/loader.py +760 -0
  111. sqlspec/migrations/__init__.py +35 -0
  112. sqlspec/migrations/base.py +414 -0
  113. sqlspec/migrations/commands.py +443 -0
  114. sqlspec/migrations/loaders.py +402 -0
  115. sqlspec/migrations/runner.py +213 -0
  116. sqlspec/migrations/tracker.py +140 -0
  117. sqlspec/migrations/utils.py +129 -0
  118. sqlspec/protocols.py +407 -0
  119. sqlspec/py.typed +0 -0
  120. sqlspec/storage/__init__.py +23 -0
  121. sqlspec/storage/backends/__init__.py +0 -0
  122. sqlspec/storage/backends/base.py +163 -0
  123. sqlspec/storage/backends/fsspec.py +386 -0
  124. sqlspec/storage/backends/obstore.py +459 -0
  125. sqlspec/storage/capabilities.py +102 -0
  126. sqlspec/storage/registry.py +239 -0
  127. sqlspec/typing.py +299 -0
  128. sqlspec/utils/__init__.py +3 -0
  129. sqlspec/utils/correlation.py +150 -0
  130. sqlspec/utils/deprecation.py +106 -0
  131. sqlspec/utils/fixtures.cpython-312-aarch64-linux-gnu.so +0 -0
  132. sqlspec/utils/fixtures.py +58 -0
  133. sqlspec/utils/logging.py +127 -0
  134. sqlspec/utils/module_loader.py +89 -0
  135. sqlspec/utils/serializers.py +4 -0
  136. sqlspec/utils/singleton.py +32 -0
  137. sqlspec/utils/sync_tools.cpython-312-aarch64-linux-gnu.so +0 -0
  138. sqlspec/utils/sync_tools.py +237 -0
  139. sqlspec/utils/text.cpython-312-aarch64-linux-gnu.so +0 -0
  140. sqlspec/utils/text.py +96 -0
  141. sqlspec/utils/type_guards.cpython-312-aarch64-linux-gnu.so +0 -0
  142. sqlspec/utils/type_guards.py +1139 -0
  143. sqlspec-0.16.1.dist-info/METADATA +365 -0
  144. sqlspec-0.16.1.dist-info/RECORD +148 -0
  145. sqlspec-0.16.1.dist-info/WHEEL +7 -0
  146. sqlspec-0.16.1.dist-info/entry_points.txt +2 -0
  147. sqlspec-0.16.1.dist-info/licenses/LICENSE +21 -0
  148. sqlspec-0.16.1.dist-info/licenses/NOTICE +29 -0
sqlspec/_typing.py ADDED
@@ -0,0 +1,680 @@
1
+ # ruff: noqa: RUF100, PLR0913, A002, DOC201, PLR6301, PLR0917, ARG004, ARG002, ARG001
2
+ """Wrapper around library classes for compatibility when libraries are installed."""
3
+
4
+ import enum
5
+ from collections.abc import Iterable, Mapping
6
+ from dataclasses import dataclass
7
+ from enum import Enum
8
+ from importlib.util import find_spec
9
+ from typing import Any, ClassVar, Final, Optional, Protocol, Union, cast, runtime_checkable
10
+
11
+ from typing_extensions import Literal, TypeVar, dataclass_transform
12
+
13
+
14
+ @runtime_checkable
15
+ class DataclassProtocol(Protocol):
16
+ """Protocol for instance checking dataclasses."""
17
+
18
+ __dataclass_fields__: "ClassVar[dict[str, Any]]"
19
+
20
+
21
+ T = TypeVar("T")
22
+ T_co = TypeVar("T_co", covariant=True)
23
+
24
+ # Always define stub types for type checking
25
+
26
+
27
+ class BaseModelStub:
28
+ """Placeholder implementation."""
29
+
30
+ model_fields: ClassVar[dict[str, Any]] = {}
31
+ __slots__ = ("__dict__", "__pydantic_extra__", "__pydantic_fields_set__", "__pydantic_private__")
32
+
33
+ def __init__(self, **data: Any) -> None:
34
+ for key, value in data.items():
35
+ setattr(self, key, value)
36
+
37
+ def model_dump( # noqa: PLR0913
38
+ self,
39
+ /,
40
+ *,
41
+ include: "Optional[Any]" = None, # noqa: ARG002
42
+ exclude: "Optional[Any]" = None, # noqa: ARG002
43
+ context: "Optional[Any]" = None, # noqa: ARG002
44
+ by_alias: bool = False, # noqa: ARG002
45
+ exclude_unset: bool = False, # noqa: ARG002
46
+ exclude_defaults: bool = False, # noqa: ARG002
47
+ exclude_none: bool = False, # noqa: ARG002
48
+ round_trip: bool = False, # noqa: ARG002
49
+ warnings: "Union[bool, Literal['none', 'warn', 'error']]" = True, # noqa: ARG002
50
+ serialize_as_any: bool = False, # noqa: ARG002
51
+ ) -> "dict[str, Any]":
52
+ """Placeholder implementation."""
53
+ return {k: v for k, v in self.__dict__.items() if not k.startswith("_")}
54
+
55
+ def model_dump_json( # noqa: PLR0913
56
+ self,
57
+ /,
58
+ *,
59
+ include: "Optional[Any]" = None, # noqa: ARG002
60
+ exclude: "Optional[Any]" = None, # noqa: ARG002
61
+ context: "Optional[Any]" = None, # noqa: ARG002
62
+ by_alias: bool = False, # noqa: ARG002
63
+ exclude_unset: bool = False, # noqa: ARG002
64
+ exclude_defaults: bool = False, # noqa: ARG002
65
+ exclude_none: bool = False, # noqa: ARG002
66
+ round_trip: bool = False, # noqa: ARG002
67
+ warnings: "Union[bool, Literal['none', 'warn', 'error']]" = True, # noqa: ARG002
68
+ serialize_as_any: bool = False, # noqa: ARG002
69
+ ) -> str:
70
+ """Placeholder implementation."""
71
+ return "{}"
72
+
73
+
74
+ class TypeAdapterStub:
75
+ """Placeholder implementation."""
76
+
77
+ def __init__(
78
+ self,
79
+ type: Any, # noqa: A002
80
+ *,
81
+ config: "Optional[Any]" = None, # noqa: ARG002
82
+ _parent_depth: int = 2, # noqa: ARG002
83
+ module: "Optional[str]" = None, # noqa: ARG002
84
+ ) -> None:
85
+ """Initialize."""
86
+ self._type = type
87
+
88
+ def validate_python( # noqa: PLR0913
89
+ self,
90
+ object: Any,
91
+ /,
92
+ *,
93
+ strict: "Optional[bool]" = None, # noqa: ARG002
94
+ from_attributes: "Optional[bool]" = None, # noqa: ARG002
95
+ context: "Optional[dict[str, Any]]" = None, # noqa: ARG002
96
+ experimental_allow_partial: "Union[bool, Literal['off', 'on', 'trailing-strings']]" = False, # noqa: ARG002
97
+ ) -> Any:
98
+ """Validate Python object."""
99
+ return object
100
+
101
+
102
+ @dataclass
103
+ class FailFastStub:
104
+ """Placeholder implementation for FailFast."""
105
+
106
+ fail_fast: bool = True
107
+
108
+
109
+ # Try to import real implementations at runtime
110
+ try:
111
+ from pydantic import BaseModel as _RealBaseModel
112
+ from pydantic import FailFast as _RealFailFast
113
+ from pydantic import TypeAdapter as _RealTypeAdapter
114
+
115
+ BaseModel = _RealBaseModel
116
+ TypeAdapter = _RealTypeAdapter
117
+ FailFast = _RealFailFast
118
+ PYDANTIC_INSTALLED = True # pyright: ignore[reportConstantRedefinition]
119
+ except ImportError:
120
+ BaseModel = BaseModelStub # type: ignore[assignment,misc]
121
+ TypeAdapter = TypeAdapterStub # type: ignore[assignment,misc]
122
+ FailFast = FailFastStub # type: ignore[assignment,misc]
123
+ PYDANTIC_INSTALLED = False # pyright: ignore[reportConstantRedefinition]
124
+
125
+ # Always define stub types for msgspec
126
+
127
+
128
+ @dataclass_transform()
129
+ class StructStub:
130
+ """Placeholder implementation."""
131
+
132
+ __struct_fields__: ClassVar[tuple[str, ...]] = ()
133
+ __slots__ = ()
134
+
135
+ def __init__(self, **kwargs: Any) -> None:
136
+ for key, value in kwargs.items():
137
+ setattr(self, key, value)
138
+
139
+
140
+ def convert_stub( # noqa: PLR0913
141
+ obj: Any, # noqa: ARG001
142
+ type: Any, # noqa: A002,ARG001
143
+ *,
144
+ strict: bool = True, # noqa: ARG001
145
+ from_attributes: bool = False, # noqa: ARG001
146
+ dec_hook: "Optional[Any]" = None, # noqa: ARG001
147
+ builtin_types: "Optional[Any]" = None, # noqa: ARG001
148
+ str_keys: bool = False, # noqa: ARG001
149
+ ) -> Any:
150
+ """Placeholder implementation."""
151
+ return {}
152
+
153
+
154
+ class UnsetTypeStub(enum.Enum):
155
+ UNSET = "UNSET"
156
+
157
+
158
+ UNSET_STUB = UnsetTypeStub.UNSET
159
+
160
+ # Try to import real implementations at runtime
161
+ try:
162
+ from msgspec import UNSET as _REAL_UNSET
163
+ from msgspec import Struct as _RealStruct
164
+ from msgspec import UnsetType as _RealUnsetType
165
+ from msgspec import convert as _real_convert
166
+
167
+ Struct = _RealStruct
168
+ UnsetType = _RealUnsetType
169
+ UNSET = _REAL_UNSET
170
+ convert = _real_convert
171
+ MSGSPEC_INSTALLED = True # pyright: ignore[reportConstantRedefinition]
172
+ except ImportError:
173
+ Struct = StructStub # type: ignore[assignment,misc]
174
+ UnsetType = UnsetTypeStub # type: ignore[assignment,misc]
175
+ UNSET = UNSET_STUB # type: ignore[assignment] # pyright: ignore[reportConstantRedefinition]
176
+ convert = convert_stub
177
+ MSGSPEC_INSTALLED = False # pyright: ignore[reportConstantRedefinition]
178
+
179
+
180
+ # Always define stub type for DTOData
181
+ @runtime_checkable
182
+ class DTODataStub(Protocol[T]):
183
+ """Placeholder implementation."""
184
+
185
+ __slots__ = ("_backend", "_data_as_builtins")
186
+
187
+ def __init__(self, backend: Any, data_as_builtins: Any) -> None:
188
+ """Initialize."""
189
+
190
+ def create_instance(self, **kwargs: Any) -> T:
191
+ return cast("T", kwargs)
192
+
193
+ def update_instance(self, instance: T, **kwargs: Any) -> T:
194
+ """Update instance."""
195
+ return cast("T", kwargs)
196
+
197
+ def as_builtins(self) -> Any:
198
+ """Convert to builtins."""
199
+ return {}
200
+
201
+
202
+ # Try to import real implementation at runtime
203
+ try:
204
+ from litestar.dto.data_structures import DTOData as _RealDTOData # pyright: ignore[reportUnknownVariableType]
205
+
206
+ DTOData = _RealDTOData
207
+ LITESTAR_INSTALLED = True # pyright: ignore[reportConstantRedefinition]
208
+ except ImportError:
209
+ DTOData = DTODataStub # type: ignore[assignment,misc]
210
+ LITESTAR_INSTALLED = False # pyright: ignore[reportConstantRedefinition]
211
+
212
+
213
+ # Always define stub types for attrs
214
+ @dataclass_transform()
215
+ class AttrsInstanceStub:
216
+ """Placeholder Implementation for attrs classes"""
217
+
218
+ __attrs_attrs__: ClassVar[tuple[Any, ...]] = ()
219
+ __slots__ = ()
220
+
221
+ def __init__(self, **kwargs: Any) -> None:
222
+ for key, value in kwargs.items():
223
+ setattr(self, key, value)
224
+
225
+ def __repr__(self) -> str:
226
+ return f"{self.__class__.__name__}()"
227
+
228
+
229
+ def attrs_asdict_stub(*args: Any, **kwargs: Any) -> "dict[str, Any]": # noqa: ARG001
230
+ """Placeholder implementation"""
231
+ return {}
232
+
233
+
234
+ def attrs_define_stub(*args: Any, **kwargs: Any) -> Any: # noqa: ARG001
235
+ """Placeholder implementation"""
236
+ return lambda cls: cls # pyright: ignore[reportUnknownVariableType,reportUnknownLambdaType]
237
+
238
+
239
+ def attrs_field_stub(*args: Any, **kwargs: Any) -> Any: # noqa: ARG001
240
+ """Placeholder implementation"""
241
+ return None
242
+
243
+
244
+ def attrs_fields_stub(*args: Any, **kwargs: Any) -> "tuple[Any, ...]": # noqa: ARG001
245
+ """Placeholder implementation"""
246
+ return ()
247
+
248
+
249
+ def attrs_has_stub(*args: Any, **kwargs: Any) -> bool: # noqa: ARG001
250
+ """Placeholder implementation"""
251
+ return False
252
+
253
+
254
+ # Try to import real implementations at runtime
255
+ try:
256
+ from attrs import AttrsInstance as _RealAttrsInstance # pyright: ignore
257
+ from attrs import asdict as _real_attrs_asdict
258
+ from attrs import define as _real_attrs_define
259
+ from attrs import field as _real_attrs_field
260
+ from attrs import fields as _real_attrs_fields
261
+ from attrs import has as _real_attrs_has
262
+
263
+ AttrsInstance = _RealAttrsInstance
264
+ attrs_asdict = _real_attrs_asdict
265
+ attrs_define = _real_attrs_define
266
+ attrs_field = _real_attrs_field
267
+ attrs_fields = _real_attrs_fields
268
+ attrs_has = _real_attrs_has
269
+ ATTRS_INSTALLED = True # pyright: ignore[reportConstantRedefinition]
270
+ except ImportError:
271
+ AttrsInstance = AttrsInstanceStub # type: ignore[misc]
272
+ attrs_asdict = attrs_asdict_stub
273
+ attrs_define = attrs_define_stub
274
+ attrs_field = attrs_field_stub
275
+ attrs_fields = attrs_fields_stub
276
+ attrs_has = attrs_has_stub # type: ignore[assignment]
277
+ ATTRS_INSTALLED = False # pyright: ignore[reportConstantRedefinition]
278
+
279
+ try:
280
+ from cattrs import structure as cattrs_structure
281
+ from cattrs import unstructure as cattrs_unstructure
282
+
283
+ CATTRS_INSTALLED = True # pyright: ignore[reportConstantRedefinition]
284
+ except ImportError:
285
+
286
+ def cattrs_unstructure(*args: Any, **kwargs: Any) -> Any: # noqa: ARG001
287
+ """Placeholder implementation"""
288
+ return {}
289
+
290
+ def cattrs_structure(*args: Any, **kwargs: Any) -> Any: # noqa: ARG001
291
+ """Placeholder implementation"""
292
+ return {}
293
+
294
+ CATTRS_INSTALLED = False # pyright: ignore[reportConstantRedefinition] # pyright: ignore[reportConstantRedefinition]
295
+
296
+
297
+ class EmptyEnum(Enum):
298
+ """A sentinel enum used as placeholder."""
299
+
300
+ EMPTY = 0
301
+
302
+
303
+ EmptyType = Union[Literal[EmptyEnum.EMPTY], UnsetType]
304
+ Empty: Final = EmptyEnum.EMPTY
305
+
306
+
307
+ @runtime_checkable
308
+ class ArrowTableResult(Protocol):
309
+ """This is a typed shim for pyarrow.Table."""
310
+
311
+ def to_batches(self, batch_size: int) -> Any:
312
+ return None
313
+
314
+ @property
315
+ def num_rows(self) -> int:
316
+ return 0
317
+
318
+ @property
319
+ def num_columns(self) -> int:
320
+ return 0
321
+
322
+ def to_pydict(self) -> dict[str, Any]:
323
+ return {}
324
+
325
+ def to_string(self) -> str:
326
+ return ""
327
+
328
+ def from_arrays(
329
+ self,
330
+ arrays: list[Any],
331
+ names: "Optional[list[str]]" = None,
332
+ schema: "Optional[Any]" = None,
333
+ metadata: "Optional[Mapping[str, Any]]" = None,
334
+ ) -> Any:
335
+ return None
336
+
337
+ def from_pydict(
338
+ self, mapping: dict[str, Any], schema: "Optional[Any]" = None, metadata: "Optional[Mapping[str, Any]]" = None
339
+ ) -> Any:
340
+ return None
341
+
342
+ def from_batches(self, batches: Iterable[Any], schema: Optional[Any] = None) -> Any:
343
+ return None
344
+
345
+
346
+ @runtime_checkable
347
+ class ArrowRecordBatchResult(Protocol):
348
+ """This is a typed shim for pyarrow.RecordBatch."""
349
+
350
+ def num_rows(self) -> int:
351
+ return 0
352
+
353
+ def num_columns(self) -> int:
354
+ return 0
355
+
356
+ def to_pydict(self) -> dict[str, Any]:
357
+ return {}
358
+
359
+ def to_pandas(self) -> Any:
360
+ return None
361
+
362
+ def schema(self) -> Any:
363
+ return None
364
+
365
+ def column(self, i: int) -> Any:
366
+ return None
367
+
368
+ def slice(self, offset: int = 0, length: "Optional[int]" = None) -> Any:
369
+ return None
370
+
371
+
372
+ try:
373
+ from pyarrow import RecordBatch as ArrowRecordBatch
374
+ from pyarrow import Table as ArrowTable
375
+
376
+ PYARROW_INSTALLED = True
377
+ except ImportError:
378
+ ArrowTable = ArrowTableResult # type: ignore[assignment,misc]
379
+ ArrowRecordBatch = ArrowRecordBatchResult # type: ignore[assignment,misc]
380
+
381
+ PYARROW_INSTALLED = False # pyright: ignore[reportConstantRedefinition]
382
+
383
+
384
+ try:
385
+ from opentelemetry import trace # pyright: ignore[reportMissingImports, reportAssignmentType]
386
+ from opentelemetry.trace import ( # pyright: ignore[reportMissingImports, reportAssignmentType]
387
+ Span, # pyright: ignore[reportMissingImports, reportAssignmentType]
388
+ Status,
389
+ StatusCode,
390
+ Tracer, # pyright: ignore[reportMissingImports, reportAssignmentType]
391
+ )
392
+
393
+ OPENTELEMETRY_INSTALLED = True # pyright: ignore[reportConstantRedefinition]
394
+ except ImportError:
395
+ # Define shims for when opentelemetry is not installed
396
+
397
+ class Span: # type: ignore[no-redef]
398
+ def set_attribute(self, key: str, value: Any) -> None:
399
+ return None
400
+
401
+ def record_exception(
402
+ self,
403
+ exception: "Exception",
404
+ attributes: "Optional[Mapping[str, Any]]" = None,
405
+ timestamp: "Optional[int]" = None,
406
+ escaped: bool = False,
407
+ ) -> None:
408
+ return None
409
+
410
+ def set_status(self, status: Any, description: "Optional[str]" = None) -> None:
411
+ return None
412
+
413
+ def end(self, end_time: "Optional[int]" = None) -> None:
414
+ return None
415
+
416
+ def __enter__(self) -> "Span":
417
+ return self # type: ignore[return-value]
418
+
419
+ def __exit__(self, exc_type: object, exc_val: object, exc_tb: object) -> None:
420
+ return None
421
+
422
+ class Tracer: # type: ignore[no-redef]
423
+ def start_span(
424
+ self,
425
+ name: str,
426
+ context: Any = None,
427
+ kind: Any = None,
428
+ attributes: Any = None,
429
+ links: Any = None,
430
+ start_time: Any = None,
431
+ record_exception: bool = True,
432
+ set_status_on_exception: bool = True,
433
+ ) -> Span:
434
+ return Span() # type: ignore[abstract]
435
+
436
+ class _TraceModule:
437
+ def get_tracer(
438
+ self,
439
+ instrumenting_module_name: str,
440
+ instrumenting_library_version: "Optional[str]" = None,
441
+ schema_url: "Optional[str]" = None,
442
+ tracer_provider: Any = None,
443
+ ) -> Tracer:
444
+ return Tracer() # type: ignore[abstract] # pragma: no cover
445
+
446
+ TracerProvider = type(None) # Shim for TracerProvider if needed elsewhere
447
+ StatusCode = type(None) # Shim for StatusCode
448
+ Status = type(None) # Shim for Status
449
+
450
+ trace = _TraceModule() # type: ignore[assignment]
451
+ StatusCode = trace.StatusCode # type: ignore[misc]
452
+ Status = trace.Status # type: ignore[misc]
453
+ OPENTELEMETRY_INSTALLED = False # pyright: ignore[reportConstantRedefinition] # pyright: ignore[reportConstantRedefinition]
454
+
455
+
456
+ try:
457
+ from prometheus_client import ( # pyright: ignore[reportMissingImports, reportAssignmentType]
458
+ Counter, # pyright: ignore[reportAssignmentType]
459
+ Gauge, # pyright: ignore[reportAssignmentType]
460
+ Histogram, # pyright: ignore[reportAssignmentType]
461
+ )
462
+
463
+ PROMETHEUS_INSTALLED = True # pyright: ignore[reportConstantRedefinition]
464
+ except ImportError:
465
+ # Define shims for when prometheus_client is not installed
466
+
467
+ class _Metric: # Base shim for metrics
468
+ def __init__(
469
+ self,
470
+ name: str,
471
+ documentation: str,
472
+ labelnames: tuple[str, ...] = (),
473
+ namespace: str = "",
474
+ subsystem: str = "",
475
+ unit: str = "",
476
+ registry: Any = None,
477
+ ejemplar_fn: Any = None,
478
+ ) -> None:
479
+ return None
480
+
481
+ def labels(self, *labelvalues: str, **labelkwargs: str) -> "_MetricInstance":
482
+ return _MetricInstance()
483
+
484
+ class _MetricInstance:
485
+ def inc(self, amount: float = 1) -> None:
486
+ return None
487
+
488
+ def dec(self, amount: float = 1) -> None:
489
+ return None
490
+
491
+ def set(self, value: float) -> None:
492
+ return None
493
+
494
+ def observe(self, amount: float) -> None:
495
+ return None
496
+
497
+ class Counter(_Metric): # type: ignore[no-redef]
498
+ def labels(self, *labelvalues: str, **labelkwargs: str) -> _MetricInstance:
499
+ return _MetricInstance() # pragma: no cover
500
+
501
+ class Gauge(_Metric): # type: ignore[no-redef]
502
+ def labels(self, *labelvalues: str, **labelkwargs: str) -> _MetricInstance:
503
+ return _MetricInstance() # pragma: no cover
504
+
505
+ class Histogram(_Metric): # type: ignore[no-redef]
506
+ def labels(self, *labelvalues: str, **labelkwargs: str) -> _MetricInstance:
507
+ return _MetricInstance() # pragma: no cover
508
+
509
+ PROMETHEUS_INSTALLED = False # pyright: ignore[reportConstantRedefinition] # pyright: ignore[reportConstantRedefinition]
510
+
511
+
512
+ try:
513
+ import aiosql # pyright: ignore[reportMissingImports, reportAssignmentType]
514
+ from aiosql.types import ( # pyright: ignore[reportMissingImports, reportAssignmentType]
515
+ AsyncDriverAdapterProtocol as AiosqlAsyncProtocol, # pyright: ignore[reportMissingImports, reportAssignmentType]
516
+ )
517
+ from aiosql.types import ( # pyright: ignore[reportMissingImports, reportAssignmentType]
518
+ DriverAdapterProtocol as AiosqlProtocol, # pyright: ignore[reportMissingImports, reportAssignmentType]
519
+ )
520
+ from aiosql.types import ParamType as AiosqlParamType # pyright: ignore[reportMissingImports, reportAssignmentType]
521
+ from aiosql.types import (
522
+ SQLOperationType as AiosqlSQLOperationType, # pyright: ignore[reportMissingImports, reportAssignmentType]
523
+ )
524
+ from aiosql.types import ( # pyright: ignore[reportMissingImports, reportAssignmentType]
525
+ SyncDriverAdapterProtocol as AiosqlSyncProtocol, # pyright: ignore[reportMissingImports, reportAssignmentType]
526
+ )
527
+
528
+ AIOSQL_INSTALLED = True # pyright: ignore[reportConstantRedefinition]
529
+ except ImportError:
530
+ # Define shims for when aiosql is not installed
531
+
532
+ class _AiosqlShim:
533
+ """Placeholder aiosql module"""
534
+
535
+ @staticmethod
536
+ def from_path(sql_path: str, driver_adapter: Any, **kwargs: Any) -> Any:
537
+ """Placeholder from_path method"""
538
+ return None # pragma: no cover
539
+
540
+ @staticmethod
541
+ def from_str(sql_str: str, driver_adapter: Any, **kwargs: Any) -> Any:
542
+ """Placeholder from_str method"""
543
+ return None # pragma: no cover
544
+
545
+ aiosql = _AiosqlShim() # type: ignore[assignment]
546
+
547
+ # Placeholder types for aiosql protocols
548
+ AiosqlParamType = Union[dict[str, Any], list[Any], tuple[Any, ...], None] # type: ignore[misc]
549
+
550
+ class AiosqlSQLOperationType(Enum): # type: ignore[no-redef]
551
+ """Enumeration of aiosql operation types."""
552
+
553
+ INSERT_RETURNING = 0
554
+ INSERT_UPDATE_DELETE = 1
555
+ INSERT_UPDATE_DELETE_MANY = 2
556
+ SCRIPT = 3
557
+ SELECT = 4
558
+ SELECT_ONE = 5
559
+ SELECT_VALUE = 6
560
+
561
+ @runtime_checkable
562
+ class AiosqlProtocol(Protocol): # type: ignore[no-redef]
563
+ """Placeholder for aiosql DriverAdapterProtocol"""
564
+
565
+ def process_sql(self, query_name: str, op_type: Any, sql: str) -> str: ...
566
+
567
+ @runtime_checkable
568
+ class AiosqlSyncProtocol(Protocol): # type: ignore[no-redef]
569
+ """Placeholder for aiosql SyncDriverAdapterProtocol"""
570
+
571
+ is_aio_driver: "ClassVar[bool]"
572
+
573
+ def process_sql(self, query_name: str, op_type: Any, sql: str) -> str: ...
574
+ def select(
575
+ self, conn: Any, query_name: str, sql: str, parameters: Any, record_class: "Optional[Any]" = None
576
+ ) -> Any: ...
577
+ def select_one(
578
+ self, conn: Any, query_name: str, sql: str, parameters: Any, record_class: "Optional[Any]" = None
579
+ ) -> "Optional[Any]": ...
580
+ def select_value(self, conn: Any, query_name: str, sql: str, parameters: Any) -> "Optional[Any]": ...
581
+ def select_cursor(self, conn: Any, query_name: str, sql: str, parameters: Any) -> Any: ...
582
+ def insert_update_delete(self, conn: Any, query_name: str, sql: str, parameters: Any) -> int: ...
583
+ def insert_update_delete_many(self, conn: Any, query_name: str, sql: str, parameters: Any) -> int: ...
584
+ def insert_returning(self, conn: Any, query_name: str, sql: str, parameters: Any) -> "Optional[Any]": ...
585
+
586
+ @runtime_checkable
587
+ class AiosqlAsyncProtocol(Protocol): # type: ignore[no-redef]
588
+ """Placeholder for aiosql AsyncDriverAdapterProtocol"""
589
+
590
+ is_aio_driver: "ClassVar[bool]"
591
+
592
+ def process_sql(self, query_name: str, op_type: Any, sql: str) -> str: ...
593
+ async def select(
594
+ self, conn: Any, query_name: str, sql: str, parameters: Any, record_class: "Optional[Any]" = None
595
+ ) -> Any: ...
596
+ async def select_one(
597
+ self, conn: Any, query_name: str, sql: str, parameters: Any, record_class: "Optional[Any]" = None
598
+ ) -> "Optional[Any]": ...
599
+ async def select_value(self, conn: Any, query_name: str, sql: str, parameters: Any) -> "Optional[Any]": ...
600
+ async def select_cursor(self, conn: Any, query_name: str, sql: str, parameters: Any) -> Any: ...
601
+ async def insert_update_delete(self, conn: Any, query_name: str, sql: str, parameters: Any) -> None: ...
602
+ async def insert_update_delete_many(self, conn: Any, query_name: str, sql: str, parameters: Any) -> None: ...
603
+ async def insert_returning(self, conn: Any, query_name: str, sql: str, parameters: Any) -> "Optional[Any]": ...
604
+
605
+ AIOSQL_INSTALLED = False # pyright: ignore[reportConstantRedefinition] # pyright: ignore[reportConstantRedefinition]
606
+
607
+
608
+ FSSPEC_INSTALLED = bool(find_spec("fsspec"))
609
+ OBSTORE_INSTALLED = bool(find_spec("obstore"))
610
+ PGVECTOR_INSTALLED = bool(find_spec("pgvector"))
611
+
612
+
613
+ __all__ = (
614
+ "AIOSQL_INSTALLED",
615
+ "ATTRS_INSTALLED",
616
+ "CATTRS_INSTALLED",
617
+ "FSSPEC_INSTALLED",
618
+ "LITESTAR_INSTALLED",
619
+ "MSGSPEC_INSTALLED",
620
+ "OBSTORE_INSTALLED",
621
+ "OPENTELEMETRY_INSTALLED",
622
+ "PGVECTOR_INSTALLED",
623
+ "PROMETHEUS_INSTALLED",
624
+ "PYARROW_INSTALLED",
625
+ "PYDANTIC_INSTALLED",
626
+ "UNSET",
627
+ "UNSET_STUB",
628
+ "AiosqlAsyncProtocol",
629
+ "AiosqlParamType",
630
+ "AiosqlProtocol",
631
+ "AiosqlSQLOperationType",
632
+ "AiosqlSyncProtocol",
633
+ "ArrowRecordBatch",
634
+ "ArrowRecordBatchResult",
635
+ "ArrowTable",
636
+ "ArrowTableResult",
637
+ "AttrsInstance",
638
+ "AttrsInstanceStub",
639
+ "BaseModel",
640
+ "BaseModelStub",
641
+ "Counter",
642
+ "DTOData",
643
+ "DTODataStub",
644
+ "DataclassProtocol",
645
+ "Empty",
646
+ "EmptyEnum",
647
+ "EmptyType",
648
+ "FailFast",
649
+ "FailFastStub",
650
+ "Gauge",
651
+ "Histogram",
652
+ "Span",
653
+ "Status",
654
+ "StatusCode",
655
+ "Struct",
656
+ "StructStub",
657
+ "T",
658
+ "T_co",
659
+ "Tracer",
660
+ "TypeAdapter",
661
+ "TypeAdapterStub",
662
+ "UnsetType",
663
+ "UnsetTypeStub",
664
+ "aiosql",
665
+ "attrs_asdict",
666
+ "attrs_asdict_stub",
667
+ "attrs_define",
668
+ "attrs_define_stub",
669
+ "attrs_field",
670
+ "attrs_field_stub",
671
+ "attrs_fields",
672
+ "attrs_fields_stub",
673
+ "attrs_has",
674
+ "attrs_has_stub",
675
+ "cattrs_structure",
676
+ "cattrs_unstructure",
677
+ "convert",
678
+ "convert_stub",
679
+ "trace",
680
+ )
File without changes
@@ -0,0 +1,5 @@
1
+ from sqlspec.adapters.adbc._types import AdbcConnection
2
+ from sqlspec.adapters.adbc.config import AdbcConfig, AdbcConnectionParams
3
+ from sqlspec.adapters.adbc.driver import AdbcCursor, AdbcDriver, AdbcExceptionHandler
4
+
5
+ __all__ = ("AdbcConfig", "AdbcConnection", "AdbcConnectionParams", "AdbcCursor", "AdbcDriver", "AdbcExceptionHandler")
@@ -0,0 +1,12 @@
1
+ # pyright: reportCallIssue=false, reportAttributeAccessIssue=false, reportArgumentType=false
2
+ from typing import TYPE_CHECKING
3
+
4
+ from adbc_driver_manager.dbapi import Connection
5
+
6
+ if TYPE_CHECKING:
7
+ from typing_extensions import TypeAlias
8
+
9
+ AdbcConnection: TypeAlias = Connection
10
+ else:
11
+ AdbcConnection = Connection
12
+ __all__ = ("AdbcConnection",)