sqlspec 0.1.0__py3-none-any.whl → 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of sqlspec might be problematic. Click here for more details.
- sqlspec/__metadata__.py +1 -1
- sqlspec/_serialization.py +1 -1
- sqlspec/_typing.py +112 -0
- sqlspec/adapters/adbc/__init__.py +0 -0
- sqlspec/adapters/adbc/config.py +54 -0
- sqlspec/adapters/aiosqlite/__init__.py +3 -0
- sqlspec/adapters/aiosqlite/config.py +112 -0
- sqlspec/adapters/asyncmy/__init__.py +3 -0
- sqlspec/adapters/asyncmy/config.py +194 -0
- sqlspec/adapters/asyncpg/__init__.py +0 -0
- sqlspec/adapters/asyncpg/config.py +155 -0
- sqlspec/adapters/duckdb/__init__.py +0 -0
- sqlspec/adapters/duckdb/config.py +101 -0
- sqlspec/adapters/oracledb/__init__.py +13 -0
- sqlspec/adapters/oracledb/config/__init__.py +9 -0
- sqlspec/adapters/oracledb/config/_asyncio.py +98 -0
- sqlspec/adapters/oracledb/config/_common.py +151 -0
- sqlspec/adapters/oracledb/config/_sync.py +102 -0
- sqlspec/adapters/psycopg/__init__.py +0 -0
- sqlspec/adapters/psycopg/config/__init__.py +9 -0
- sqlspec/adapters/psycopg/config/_async.py +84 -0
- sqlspec/adapters/psycopg/config/_common.py +72 -0
- sqlspec/adapters/psycopg/config/_sync.py +84 -0
- sqlspec/adapters/sqlite/__init__.py +0 -0
- sqlspec/adapters/sqlite/config.py +109 -0
- sqlspec/config.py +16 -0
- sqlspec/exceptions.py +29 -0
- sqlspec/extensions/__init__.py +0 -0
- sqlspec/extensions/litestar/__init__.py +0 -0
- sqlspec/extensions/litestar/plugin.py +34 -0
- sqlspec/filters.py +33 -28
- sqlspec/typing.py +287 -0
- sqlspec/utils/dataclass.py +11 -3
- sqlspec/{types → utils}/empty.py +1 -1
- sqlspec-0.3.0.dist-info/METADATA +84 -0
- sqlspec-0.3.0.dist-info/RECORD +42 -0
- {sqlspec-0.1.0.dist-info → sqlspec-0.3.0.dist-info}/WHEEL +1 -1
- sqlspec-0.3.0.dist-info/licenses/NOTICE +29 -0
- sqlspec/types/protocols.py +0 -117
- sqlspec-0.1.0.dist-info/METADATA +0 -25
- sqlspec-0.1.0.dist-info/RECORD +0 -14
- /sqlspec/{types → adapters}/__init__.py +0 -0
sqlspec/typing.py
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Sequence
|
|
4
|
+
from functools import lru_cache
|
|
5
|
+
from typing import (
|
|
6
|
+
TYPE_CHECKING,
|
|
7
|
+
Annotated,
|
|
8
|
+
Any,
|
|
9
|
+
TypeVar,
|
|
10
|
+
Union,
|
|
11
|
+
cast,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
from typing_extensions import TypeAlias, TypeGuard
|
|
15
|
+
|
|
16
|
+
from sqlspec._typing import (
|
|
17
|
+
MSGSPEC_INSTALLED,
|
|
18
|
+
PYDANTIC_INSTALLED,
|
|
19
|
+
UNSET,
|
|
20
|
+
BaseModel,
|
|
21
|
+
FailFast,
|
|
22
|
+
Struct,
|
|
23
|
+
TypeAdapter,
|
|
24
|
+
convert,
|
|
25
|
+
)
|
|
26
|
+
from sqlspec.utils.dataclass import DataclassProtocol, is_dataclass_instance, simple_asdict
|
|
27
|
+
|
|
28
|
+
if TYPE_CHECKING:
|
|
29
|
+
from .filters import StatementFilter
|
|
30
|
+
|
|
31
|
+
PYDANTIC_USE_FAILFAST = False # leave permanently disabled for now
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
T = TypeVar("T")
|
|
35
|
+
|
|
36
|
+
ModelT = TypeVar("ModelT", bound="Struct | BaseModel | DataclassProtocol")
|
|
37
|
+
|
|
38
|
+
FilterTypeT = TypeVar("FilterTypeT", bound="StatementFilter")
|
|
39
|
+
"""Type variable for filter types.
|
|
40
|
+
|
|
41
|
+
:class:`~advanced_alchemy.filters.StatementFilter`
|
|
42
|
+
"""
|
|
43
|
+
ModelDictT: TypeAlias = Union[dict[str, Any], ModelT, DataclassProtocol, Struct, BaseModel]
|
|
44
|
+
"""Type alias for model dictionaries.
|
|
45
|
+
|
|
46
|
+
Represents:
|
|
47
|
+
- :type:`dict[str, Any]` | :class:`~advanced_alchemy.base.ModelProtocol` | :class:`msgspec.Struct` | :class:`pydantic.BaseModel` | :class:`litestar.dto.data_structures.DTOData` | :class:`~advanced_alchemy.base.ModelProtocol`
|
|
48
|
+
"""
|
|
49
|
+
ModelDictListT: TypeAlias = Sequence[Union[dict[str, Any], ModelT, DataclassProtocol, Struct, BaseModel]]
|
|
50
|
+
"""Type alias for model dictionary lists.
|
|
51
|
+
|
|
52
|
+
A list or sequence of any of the following:
|
|
53
|
+
- :type:`Sequence`[:type:`dict[str, Any]` | :class:`~advanced_alchemy.base.ModelProtocol` | :class:`msgspec.Struct` | :class:`pydantic.BaseModel`]
|
|
54
|
+
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@lru_cache(typed=True)
|
|
59
|
+
def get_type_adapter(f: type[T]) -> TypeAdapter[T]:
|
|
60
|
+
"""Caches and returns a pydantic type adapter.
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
f: Type to create a type adapter for.
|
|
64
|
+
|
|
65
|
+
Returns:
|
|
66
|
+
:class:`pydantic.TypeAdapter`[:class:`typing.TypeVar`[T]]
|
|
67
|
+
"""
|
|
68
|
+
if PYDANTIC_USE_FAILFAST:
|
|
69
|
+
return TypeAdapter(
|
|
70
|
+
Annotated[f, FailFast()],
|
|
71
|
+
)
|
|
72
|
+
return TypeAdapter(f)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def is_pydantic_model(v: Any) -> TypeGuard[BaseModel]:
|
|
76
|
+
"""Check if a value is a pydantic model.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
v: Value to check.
|
|
80
|
+
|
|
81
|
+
Returns:
|
|
82
|
+
bool
|
|
83
|
+
"""
|
|
84
|
+
return PYDANTIC_INSTALLED and isinstance(v, BaseModel)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def is_msgspec_model(v: Any) -> TypeGuard[Struct]:
|
|
88
|
+
"""Check if a value is a msgspec model.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
v: Value to check.
|
|
92
|
+
|
|
93
|
+
Returns:
|
|
94
|
+
bool
|
|
95
|
+
"""
|
|
96
|
+
return MSGSPEC_INSTALLED and isinstance(v, Struct)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def is_dict(v: Any) -> TypeGuard[dict[str, Any]]:
|
|
100
|
+
"""Check if a value is a dictionary.
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
v: Value to check.
|
|
104
|
+
|
|
105
|
+
Returns:
|
|
106
|
+
bool
|
|
107
|
+
"""
|
|
108
|
+
return isinstance(v, dict)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def is_dict_with_field(v: Any, field_name: str) -> TypeGuard[dict[str, Any]]:
|
|
112
|
+
"""Check if a dictionary has a specific field.
|
|
113
|
+
|
|
114
|
+
Args:
|
|
115
|
+
v: Value to check.
|
|
116
|
+
field_name: Field name to check for.
|
|
117
|
+
|
|
118
|
+
Returns:
|
|
119
|
+
bool
|
|
120
|
+
"""
|
|
121
|
+
return is_dict(v) and field_name in v
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def is_dict_without_field(v: Any, field_name: str) -> TypeGuard[dict[str, Any]]:
|
|
125
|
+
"""Check if a dictionary does not have a specific field.
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
v: Value to check.
|
|
129
|
+
field_name: Field name to check for.
|
|
130
|
+
|
|
131
|
+
Returns:
|
|
132
|
+
bool
|
|
133
|
+
"""
|
|
134
|
+
return is_dict(v) and field_name not in v
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def is_dataclass(v: Any) -> TypeGuard[DataclassProtocol]:
|
|
138
|
+
"""Check if a value is a dataclass.
|
|
139
|
+
|
|
140
|
+
Args:
|
|
141
|
+
v: Value to check.
|
|
142
|
+
|
|
143
|
+
Returns:
|
|
144
|
+
bool
|
|
145
|
+
"""
|
|
146
|
+
return is_dataclass_instance(v)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def is_dataclass_with_field(v: Any, field_name: str) -> TypeGuard[DataclassProtocol]:
|
|
150
|
+
"""Check if a dataclass has a specific field.
|
|
151
|
+
|
|
152
|
+
Args:
|
|
153
|
+
v: Value to check.
|
|
154
|
+
field_name: Field name to check for.
|
|
155
|
+
|
|
156
|
+
Returns:
|
|
157
|
+
bool
|
|
158
|
+
"""
|
|
159
|
+
return is_dataclass(v) and field_name in v.__dataclass_fields__
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def is_dataclass_without_field(v: Any, field_name: str) -> TypeGuard[DataclassProtocol]:
|
|
163
|
+
"""Check if a dataclass does not have a specific field.
|
|
164
|
+
|
|
165
|
+
Args:
|
|
166
|
+
v: Value to check.
|
|
167
|
+
field_name: Field name to check for.
|
|
168
|
+
|
|
169
|
+
Returns:
|
|
170
|
+
bool
|
|
171
|
+
"""
|
|
172
|
+
return is_dataclass(v) and field_name not in v.__dataclass_fields__
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def is_pydantic_model_with_field(v: Any, field_name: str) -> TypeGuard[BaseModel]:
|
|
176
|
+
"""Check if a pydantic model has a specific field.
|
|
177
|
+
|
|
178
|
+
Args:
|
|
179
|
+
v: Value to check.
|
|
180
|
+
field_name: Field name to check for.
|
|
181
|
+
|
|
182
|
+
Returns:
|
|
183
|
+
bool
|
|
184
|
+
"""
|
|
185
|
+
return is_pydantic_model(v) and field_name in v.model_fields
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def is_pydantic_model_without_field(v: Any, field_name: str) -> TypeGuard[BaseModel]:
|
|
189
|
+
"""Check if a pydantic model does not have a specific field.
|
|
190
|
+
|
|
191
|
+
Args:
|
|
192
|
+
v: Value to check.
|
|
193
|
+
field_name: Field name to check for.
|
|
194
|
+
|
|
195
|
+
Returns:
|
|
196
|
+
bool
|
|
197
|
+
"""
|
|
198
|
+
return not is_pydantic_model_with_field(v, field_name)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def is_msgspec_model_with_field(v: Any, field_name: str) -> TypeGuard[Struct]:
|
|
202
|
+
"""Check if a msgspec model has a specific field.
|
|
203
|
+
|
|
204
|
+
Args:
|
|
205
|
+
v: Value to check.
|
|
206
|
+
field_name: Field name to check for.
|
|
207
|
+
|
|
208
|
+
Returns:
|
|
209
|
+
bool
|
|
210
|
+
"""
|
|
211
|
+
return is_msgspec_model(v) and field_name in v.__struct_fields__
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def is_msgspec_model_without_field(v: Any, field_name: str) -> TypeGuard[Struct]:
|
|
215
|
+
"""Check if a msgspec model does not have a specific field.
|
|
216
|
+
|
|
217
|
+
Args:
|
|
218
|
+
v: Value to check.
|
|
219
|
+
field_name: Field name to check for.
|
|
220
|
+
|
|
221
|
+
Returns:
|
|
222
|
+
bool
|
|
223
|
+
"""
|
|
224
|
+
return not is_msgspec_model_with_field(v, field_name)
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def schema_dump(
|
|
228
|
+
data: dict[str, Any] | Struct | BaseModel | DataclassProtocol,
|
|
229
|
+
exclude_unset: bool = True,
|
|
230
|
+
) -> dict[str, Any]:
|
|
231
|
+
"""Dump a data object to a dictionary.
|
|
232
|
+
|
|
233
|
+
Args:
|
|
234
|
+
data: dict[str, Any] | ModelT | Struct | BaseModel | DataclassProtocol
|
|
235
|
+
exclude_unset: :type:`bool` Whether to exclude unset values.
|
|
236
|
+
|
|
237
|
+
Returns:
|
|
238
|
+
:type: dict[str, Any]
|
|
239
|
+
"""
|
|
240
|
+
if is_dataclass(data):
|
|
241
|
+
return simple_asdict(data, exclude_empty=exclude_unset)
|
|
242
|
+
if is_pydantic_model(data):
|
|
243
|
+
return data.model_dump(exclude_unset=exclude_unset)
|
|
244
|
+
if is_msgspec_model(data) and exclude_unset:
|
|
245
|
+
return {f: val for f in data.__struct_fields__ if (val := getattr(data, f, None)) != UNSET}
|
|
246
|
+
if is_msgspec_model(data) and not exclude_unset:
|
|
247
|
+
return {f: getattr(data, f, None) for f in data.__struct_fields__}
|
|
248
|
+
return cast("dict[str,Any]", data)
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
__all__ = (
|
|
252
|
+
"MSGSPEC_INSTALLED",
|
|
253
|
+
"PYDANTIC_INSTALLED",
|
|
254
|
+
"PYDANTIC_USE_FAILFAST",
|
|
255
|
+
"UNSET",
|
|
256
|
+
"BaseModel",
|
|
257
|
+
"FailFast",
|
|
258
|
+
"FilterTypeT",
|
|
259
|
+
"ModelDictListT",
|
|
260
|
+
"ModelDictT",
|
|
261
|
+
"Struct",
|
|
262
|
+
"TypeAdapter",
|
|
263
|
+
"UnsetType",
|
|
264
|
+
"convert",
|
|
265
|
+
"get_type_adapter",
|
|
266
|
+
"is_dict",
|
|
267
|
+
"is_dict_with_field",
|
|
268
|
+
"is_dict_without_field",
|
|
269
|
+
"is_msgspec_model",
|
|
270
|
+
"is_msgspec_model_with_field",
|
|
271
|
+
"is_msgspec_model_without_field",
|
|
272
|
+
"is_pydantic_model",
|
|
273
|
+
"is_pydantic_model_with_field",
|
|
274
|
+
"is_pydantic_model_without_field",
|
|
275
|
+
"schema_dump",
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
if TYPE_CHECKING:
|
|
279
|
+
if not PYDANTIC_INSTALLED:
|
|
280
|
+
from ._typing import BaseModel, FailFast, TypeAdapter
|
|
281
|
+
else:
|
|
282
|
+
from pydantic import BaseModel, FailFast, TypeAdapter # noqa: TC004
|
|
283
|
+
|
|
284
|
+
if not MSGSPEC_INSTALLED:
|
|
285
|
+
from ._typing import UNSET, Struct, UnsetType, convert
|
|
286
|
+
else:
|
|
287
|
+
from msgspec import UNSET, Struct, UnsetType, convert # noqa: TC004
|
sqlspec/utils/dataclass.py
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from dataclasses import Field, fields
|
|
4
|
-
from typing import TYPE_CHECKING,
|
|
4
|
+
from typing import TYPE_CHECKING, ClassVar, Protocol, runtime_checkable
|
|
5
5
|
|
|
6
|
-
from
|
|
6
|
+
from typing_extensions import TypeGuard
|
|
7
|
+
|
|
8
|
+
from sqlspec.utils.empty import Empty
|
|
7
9
|
|
|
8
10
|
if TYPE_CHECKING:
|
|
9
11
|
from collections.abc import Iterable
|
|
10
12
|
from collections.abc import Set as AbstractSet
|
|
11
13
|
from typing import Any
|
|
12
14
|
|
|
13
|
-
from sqlspec.types.protocols import DataclassProtocol
|
|
14
15
|
|
|
15
16
|
__all__ = (
|
|
16
17
|
"extract_dataclass_fields",
|
|
@@ -20,6 +21,13 @@ __all__ = (
|
|
|
20
21
|
)
|
|
21
22
|
|
|
22
23
|
|
|
24
|
+
@runtime_checkable
|
|
25
|
+
class DataclassProtocol(Protocol):
|
|
26
|
+
"""Protocol for instance checking dataclasses"""
|
|
27
|
+
|
|
28
|
+
__dataclass_fields__: ClassVar[dict[str, Any]]
|
|
29
|
+
|
|
30
|
+
|
|
23
31
|
def is_dataclass_instance(obj: Any) -> TypeGuard[DataclassProtocol]:
|
|
24
32
|
"""Check if an object is a dataclass instance.
|
|
25
33
|
|
sqlspec/{types → utils}/empty.py
RENAMED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sqlspec
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: SQL Experiments in Python
|
|
5
|
+
Author-email: Cody Fincher <cody@litestar.dev>
|
|
6
|
+
Maintainer-email: Litestar Developers <hello@litestar.dev>
|
|
7
|
+
License-File: NOTICE
|
|
8
|
+
Requires-Python: <4.0,>=3.9
|
|
9
|
+
Requires-Dist: eval-type-backport; python_version <= '3.9'
|
|
10
|
+
Requires-Dist: sqlglot
|
|
11
|
+
Requires-Dist: typing-extensions>=4.0.0
|
|
12
|
+
Provides-Extra: adbc
|
|
13
|
+
Requires-Dist: adbc-driver-manager; extra == 'adbc'
|
|
14
|
+
Requires-Dist: pyarrow; extra == 'adbc'
|
|
15
|
+
Provides-Extra: aioodbc
|
|
16
|
+
Requires-Dist: aioodbc; extra == 'aioodbc'
|
|
17
|
+
Provides-Extra: aiosqlite
|
|
18
|
+
Requires-Dist: aiosqlite; extra == 'aiosqlite'
|
|
19
|
+
Provides-Extra: asyncmy
|
|
20
|
+
Requires-Dist: asyncmy; extra == 'asyncmy'
|
|
21
|
+
Provides-Extra: asyncpg
|
|
22
|
+
Requires-Dist: asyncpg; extra == 'asyncpg'
|
|
23
|
+
Provides-Extra: bigquery
|
|
24
|
+
Requires-Dist: google-cloud-bigquery; extra == 'bigquery'
|
|
25
|
+
Provides-Extra: duckdb
|
|
26
|
+
Requires-Dist: duckdb; extra == 'duckdb'
|
|
27
|
+
Provides-Extra: fastapi
|
|
28
|
+
Requires-Dist: fastapi; extra == 'fastapi'
|
|
29
|
+
Provides-Extra: flask
|
|
30
|
+
Requires-Dist: flask; extra == 'flask'
|
|
31
|
+
Provides-Extra: litestar
|
|
32
|
+
Requires-Dist: litestar; extra == 'litestar'
|
|
33
|
+
Provides-Extra: msgspec
|
|
34
|
+
Requires-Dist: msgspec; extra == 'msgspec'
|
|
35
|
+
Provides-Extra: oracledb
|
|
36
|
+
Requires-Dist: oracledb; extra == 'oracledb'
|
|
37
|
+
Provides-Extra: performance
|
|
38
|
+
Requires-Dist: google-re2; (sys_platform == 'linux') and extra == 'performance'
|
|
39
|
+
Requires-Dist: sqlglot[rs]; extra == 'performance'
|
|
40
|
+
Provides-Extra: psycopg
|
|
41
|
+
Requires-Dist: psycopg[binary,pool]; extra == 'psycopg'
|
|
42
|
+
Provides-Extra: pydantic
|
|
43
|
+
Requires-Dist: pydantic; extra == 'pydantic'
|
|
44
|
+
Provides-Extra: pymssql
|
|
45
|
+
Requires-Dist: pymssql; extra == 'pymssql'
|
|
46
|
+
Provides-Extra: pymysql
|
|
47
|
+
Requires-Dist: pymysql; extra == 'pymysql'
|
|
48
|
+
Provides-Extra: spanner
|
|
49
|
+
Requires-Dist: google-cloud-spanner; extra == 'spanner'
|
|
50
|
+
Description-Content-Type: text/markdown
|
|
51
|
+
|
|
52
|
+
<!-- markdownlint-disable -->
|
|
53
|
+
<p align="center">
|
|
54
|
+
<!-- github-banner-start -->
|
|
55
|
+
<img src="https://raw.githubusercontent.com/litestar-org/branding/main/assets/Branding%20-%20SVG%20-%20Transparent/Logo%20-%20Banner%20-%20Inline%20-%20Light.svg#gh-light-mode-only" alt="Litestar Logo - Light" width="100%" height="auto" />
|
|
56
|
+
<img src="https://raw.githubusercontent.com/litestar-org/branding/main/assets/Branding%20-%20SVG%20-%20Transparent/Logo%20-%20Banner%20-%20Inline%20-%20Dark.svg#gh-dark-mode-only" alt="Litestar Logo - Dark" width="100%" height="auto" />
|
|
57
|
+
<!-- github-banner-end -->
|
|
58
|
+
|
|
59
|
+
</p>
|
|
60
|
+
<div align="center">
|
|
61
|
+
<!-- markdownlint-restore -->
|
|
62
|
+
|
|
63
|
+
# SQLSpec
|
|
64
|
+
|
|
65
|
+
SQL Experiments in Python
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
## Minimal SQL Abstractions for Python.
|
|
69
|
+
|
|
70
|
+
- Modern: Typed and Extensible
|
|
71
|
+
- Multi-database: SQLite, Postgres, DuckDB, MySQL, Oracle, SQL Server, Spanner, Big Query, and more...
|
|
72
|
+
- Easy ability to manipulate and add filters to queries
|
|
73
|
+
- Validate and Convert between dialects with `sqlglot`
|
|
74
|
+
- and more...
|
|
75
|
+
|
|
76
|
+
## Can it do `X`?
|
|
77
|
+
|
|
78
|
+
- Probably not currently; but, if it makes sense we can add enhancements.
|
|
79
|
+
|
|
80
|
+
## Inspiration
|
|
81
|
+
|
|
82
|
+
`aiosql` is the primary influence for this library. However, I wanted to be able to use the query interface from `aiosql` a bit more flexibly.
|
|
83
|
+
|
|
84
|
+
Why not add it to `aiosql`? Where it makes sense, many of these changes will likely get submitted to aiosql as a PR (`spanner` and `bigquery` drivers are likely the starting point.)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
sqlspec/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
|
|
2
|
+
sqlspec/__metadata__.py,sha256=Vw99abV_UQNVH2jB0IBa9-8emyZQcXm1J9eMtLxFX2Y,496
|
|
3
|
+
sqlspec/_serialization.py,sha256=OL4x0Rz5UjF7RgAKqhYChi5qSS_ImtaVrIlA4DhIKUE,824
|
|
4
|
+
sqlspec/_typing.py,sha256=8tk4KqqO8OLDe-PIow2oaAnzgHOiFb74Mx7yuoAZUgI,2814
|
|
5
|
+
sqlspec/config.py,sha256=BOX_V_q2MOP33tK0ISpYaiQJt3zrvK4D_JIBD9FOixY,272
|
|
6
|
+
sqlspec/exceptions.py,sha256=fhCOILBj0J7HJP67BNSC0d9YUbW8QpZPXM55xJJzE8A,3039
|
|
7
|
+
sqlspec/filters.py,sha256=UtDJVpABSxHLkadiswMcneBsvawmWsz3Bq7wLxLJn74,3454
|
|
8
|
+
sqlspec/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
sqlspec/typing.py,sha256=9gXd4qAxZxejXo1NpGDKflsmWu5kQomB3fps3l4EbZs,7289
|
|
10
|
+
sqlspec/adapters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
sqlspec/adapters/adbc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
+
sqlspec/adapters/adbc/config.py,sha256=lCOoewYM0u9GHHGkux0FbSRAri4oIi91_Zrs_x3FkdQ,1745
|
|
13
|
+
sqlspec/adapters/aiosqlite/__init__.py,sha256=PLqWg24l3TooJvqA0Xf1WErrxtqwo8DEoL_Zp2iSCzs,68
|
|
14
|
+
sqlspec/adapters/aiosqlite/config.py,sha256=SM1nkRnrIzeUUMtL1cmMEh75epkCKtII1D-Wjgnc7ZY,4308
|
|
15
|
+
sqlspec/adapters/asyncmy/__init__.py,sha256=o0R_Azae3FHiSZ1TQ5ZjyCneDOuvnEeMjmSkhuiKoWo,103
|
|
16
|
+
sqlspec/adapters/asyncmy/config.py,sha256=0_0tdx7JvTIR1DZuaHeLg8IaK5Rv3li6dVKVOf8k_AI,5956
|
|
17
|
+
sqlspec/adapters/asyncpg/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
|
+
sqlspec/adapters/asyncpg/config.py,sha256=Q1TgWtI2lrn0SDtP8KTVfJ2f1I6XhOUPSujKngWIf5A,6306
|
|
19
|
+
sqlspec/adapters/duckdb/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
|
+
sqlspec/adapters/duckdb/config.py,sha256=2LfJnZYMcbXAR9BQ66Y9rhh7R_u6PI2GHApGo1Oy04k,3461
|
|
21
|
+
sqlspec/adapters/oracledb/__init__.py,sha256=fFQ2xOxFcgpr-ug4AVv430irnJgBRUINvt4sL3qzyBw,275
|
|
22
|
+
sqlspec/adapters/oracledb/config/__init__.py,sha256=XoHgInT4IbXjDg5ax3ncuUoVvnYB5qQjI-Ib7gwSycU,338
|
|
23
|
+
sqlspec/adapters/oracledb/config/_asyncio.py,sha256=qB-1jPwjNdHYrDYjjQqR-q1KqMKFXESk-T9aZtdrwDI,3280
|
|
24
|
+
sqlspec/adapters/oracledb/config/_common.py,sha256=VwMbZAX-jJ2kyAbtgRUOWDvO12nXsb68wO-3d3L9Wz4,6183
|
|
25
|
+
sqlspec/adapters/oracledb/config/_sync.py,sha256=m_OkErwBKvQrFU6Q9PuduSJu_vHbmZl1gWYbpw6b22I,3268
|
|
26
|
+
sqlspec/adapters/psycopg/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
+
sqlspec/adapters/psycopg/config/__init__.py,sha256=pXI9Pa2VYESTchPgM3tt5kFF8tsmgq-ksZRGR6pgiUQ,280
|
|
28
|
+
sqlspec/adapters/psycopg/config/_async.py,sha256=mdqFanrnodTq8u3THim3KkiNmEoIQpsKmBpJSaRiGTc,3004
|
|
29
|
+
sqlspec/adapters/psycopg/config/_common.py,sha256=F4rwAlAcVM2HgDVnD87Pda0DjVV-oqzDUd0TofqnUL0,2766
|
|
30
|
+
sqlspec/adapters/psycopg/config/_sync.py,sha256=YILMCmOpGX4E62hepuM0WgT7aPQpwbZpUwjAonmjUYc,2860
|
|
31
|
+
sqlspec/adapters/sqlite/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
|
+
sqlspec/adapters/sqlite/config.py,sha256=0c_eN01mEcM-OIiaDgs-4fM20z03QivANGxAuxJOisA,4117
|
|
33
|
+
sqlspec/extensions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
34
|
+
sqlspec/extensions/litestar/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
35
|
+
sqlspec/extensions/litestar/plugin.py,sha256=oiBFfRffNvy_vnGptREd6JYZGB6Yd98KbtVct_VcW0A,837
|
|
36
|
+
sqlspec/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
37
|
+
sqlspec/utils/dataclass.py,sha256=g88yP0Pi3EiF8N-Npuo-D6QpPExCLuUvJCO0U_3lHkQ,4301
|
|
38
|
+
sqlspec/utils/empty.py,sha256=u5KC3HUF7MolHYs9kSt7Uq-jTIl0x9gJqf-jX0y5_BY,349
|
|
39
|
+
sqlspec-0.3.0.dist-info/METADATA,sha256=DCx_OsG0w07rjQx01g2av9VxMgQZsmDWcZl0nsqJU8A,3222
|
|
40
|
+
sqlspec-0.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
41
|
+
sqlspec-0.3.0.dist-info/licenses/NOTICE,sha256=Lyir8ozXWov7CyYS4huVaOCNrtgL17P-bNV-5daLntQ,1634
|
|
42
|
+
sqlspec-0.3.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Early versions of this utility adapt code from `aoisql`.
|
|
2
|
+
# BSD 2-Clause License
|
|
3
|
+
Copyright (c) 2014-2017, Honza Pokorny
|
|
4
|
+
Copyright (c) 2018, William Vaughn
|
|
5
|
+
All rights reserved.
|
|
6
|
+
|
|
7
|
+
Redistribution and use in source and binary forms, with or without
|
|
8
|
+
modification, are permitted provided that the following conditions are met:
|
|
9
|
+
|
|
10
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
11
|
+
list of conditions and the following disclaimer.
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
17
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
18
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
19
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
20
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
21
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
22
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
23
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
24
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
+
|
|
27
|
+
The views and conclusions contained in the software and documentation are those
|
|
28
|
+
of the authors and should not be interpreted as representing official policies,
|
|
29
|
+
either expressed or implied, of the aiosql Project.
|
sqlspec/types/protocols.py
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: 2023-present Cody Fincher <codyfincher@google.com>
|
|
2
|
-
#
|
|
3
|
-
# SPDX-License-Identifier: MIT
|
|
4
|
-
from __future__ import annotations
|
|
5
|
-
|
|
6
|
-
from collections.abc import Collection, Iterable
|
|
7
|
-
from typing import Any, ClassVar, Protocol, TypeVar, runtime_checkable
|
|
8
|
-
|
|
9
|
-
__all__ = (
|
|
10
|
-
"DataclassProtocol",
|
|
11
|
-
"InstantiableCollection",
|
|
12
|
-
"Logger",
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class Logger(Protocol):
|
|
17
|
-
"""Logger protocol."""
|
|
18
|
-
|
|
19
|
-
def debug(self, event: str, *args: Any, **kwargs: Any) -> Any:
|
|
20
|
-
"""Output a log message at 'DEBUG' level.
|
|
21
|
-
|
|
22
|
-
Args:
|
|
23
|
-
event: Log message.
|
|
24
|
-
*args: Any args.
|
|
25
|
-
**kwargs: Any kwargs.
|
|
26
|
-
"""
|
|
27
|
-
|
|
28
|
-
def info(self, event: str, *args: Any, **kwargs: Any) -> Any:
|
|
29
|
-
"""Output a log message at 'INFO' level.
|
|
30
|
-
|
|
31
|
-
Args:
|
|
32
|
-
event: Log message.
|
|
33
|
-
*args: Any args.
|
|
34
|
-
**kwargs: Any kwargs.
|
|
35
|
-
"""
|
|
36
|
-
|
|
37
|
-
def warning(self, event: str, *args: Any, **kwargs: Any) -> Any:
|
|
38
|
-
"""Output a log message at 'WARNING' level.
|
|
39
|
-
|
|
40
|
-
Args:
|
|
41
|
-
event: Log message.
|
|
42
|
-
*args: Any args.
|
|
43
|
-
**kwargs: Any kwargs.
|
|
44
|
-
"""
|
|
45
|
-
|
|
46
|
-
def warn(self, event: str, *args: Any, **kwargs: Any) -> Any:
|
|
47
|
-
"""Output a log message at 'WARN' level.
|
|
48
|
-
|
|
49
|
-
Args:
|
|
50
|
-
event: Log message.
|
|
51
|
-
*args: Any args.
|
|
52
|
-
**kwargs: Any kwargs.
|
|
53
|
-
"""
|
|
54
|
-
|
|
55
|
-
def error(self, event: str, *args: Any, **kwargs: Any) -> Any:
|
|
56
|
-
"""Output a log message at 'ERROR' level.
|
|
57
|
-
|
|
58
|
-
Args:
|
|
59
|
-
event: Log message.
|
|
60
|
-
*args: Any args.
|
|
61
|
-
**kwargs: Any kwargs.
|
|
62
|
-
"""
|
|
63
|
-
|
|
64
|
-
def fatal(self, event: str, *args: Any, **kwargs: Any) -> Any:
|
|
65
|
-
"""Output a log message at 'FATAL' level.
|
|
66
|
-
|
|
67
|
-
Args:
|
|
68
|
-
event: Log message.
|
|
69
|
-
*args: Any args.
|
|
70
|
-
**kwargs: Any kwargs.
|
|
71
|
-
"""
|
|
72
|
-
|
|
73
|
-
def exception(self, event: str, *args: Any, **kwargs: Any) -> Any:
|
|
74
|
-
"""Log a message with level 'ERROR' on this logger. The arguments are interpreted as for debug(). Exception info
|
|
75
|
-
is added to the logging message.
|
|
76
|
-
|
|
77
|
-
Args:
|
|
78
|
-
event: Log message.
|
|
79
|
-
*args: Any args.
|
|
80
|
-
**kwargs: Any kwargs.
|
|
81
|
-
"""
|
|
82
|
-
|
|
83
|
-
def critical(self, event: str, *args: Any, **kwargs: Any) -> Any:
|
|
84
|
-
"""Output a log message at 'INFO' level.
|
|
85
|
-
|
|
86
|
-
Args:
|
|
87
|
-
event: Log message.
|
|
88
|
-
*args: Any args.
|
|
89
|
-
**kwargs: Any kwargs.
|
|
90
|
-
"""
|
|
91
|
-
|
|
92
|
-
def setLevel(self, level: int) -> None: # noqa: N802
|
|
93
|
-
"""Set the log level
|
|
94
|
-
|
|
95
|
-
Args:
|
|
96
|
-
level: Log level to set as an integer
|
|
97
|
-
|
|
98
|
-
Returns:
|
|
99
|
-
None
|
|
100
|
-
"""
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
@runtime_checkable
|
|
104
|
-
class DataclassProtocol(Protocol):
|
|
105
|
-
"""Protocol for instance checking dataclasses"""
|
|
106
|
-
|
|
107
|
-
__dataclass_fields__: ClassVar[dict[str, Any]]
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
T_co = TypeVar("T_co", covariant=True)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
@runtime_checkable
|
|
114
|
-
class InstantiableCollection(Collection[T_co], Protocol[T_co]): # pyright: ignore
|
|
115
|
-
"""A protocol for instantiable collection types."""
|
|
116
|
-
|
|
117
|
-
def __init__(self, iterable: Iterable[T_co], /) -> None: ...
|
sqlspec-0.1.0.dist-info/METADATA
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: sqlspec
|
|
3
|
-
Version: 0.1.0
|
|
4
|
-
Summary: SQL Expiriments in Python
|
|
5
|
-
Author-email: Cody Fincher <cody@litestar.dev>
|
|
6
|
-
Maintainer-email: Litestar Developers <hello@litestar.dev>
|
|
7
|
-
Requires-Python: <4.0,>=3.9
|
|
8
|
-
Requires-Dist: eval-type-backport; python_version <= '3.9'
|
|
9
|
-
Requires-Dist: typing-extensions>=4.0.0
|
|
10
|
-
Description-Content-Type: text/markdown
|
|
11
|
-
|
|
12
|
-
<!-- markdownlint-disable -->
|
|
13
|
-
<p align="center">
|
|
14
|
-
<!-- github-banner-start -->
|
|
15
|
-
<img src="https://raw.githubusercontent.com/litestar-org/branding/main/assets/Branding%20-%20SVG%20-%20Transparent/Logo%20-%20Banner%20-%20Inline%20-%20Light.svg#gh-light-mode-only" alt="Litestar Logo - Light" width="100%" height="auto" />
|
|
16
|
-
<img src="https://raw.githubusercontent.com/litestar-org/branding/main/assets/Branding%20-%20SVG%20-%20Transparent/Logo%20-%20Banner%20-%20Inline%20-%20Dark.svg#gh-dark-mode-only" alt="Litestar Logo - Dark" width="100%" height="auto" />
|
|
17
|
-
<!-- github-banner-end -->
|
|
18
|
-
|
|
19
|
-
</p>
|
|
20
|
-
<div align="center">
|
|
21
|
-
<!-- markdownlint-restore -->
|
|
22
|
-
|
|
23
|
-
# SQLSpec
|
|
24
|
-
|
|
25
|
-
SQL Expiriments in Python
|
sqlspec-0.1.0.dist-info/RECORD
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
sqlspec/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
|
|
2
|
-
sqlspec/__metadata__.py,sha256=IKK7ARcZFaxFXHrjAgeneCvbZDQi5a-6Es32B8nIkTc,496
|
|
3
|
-
sqlspec/_serialization.py,sha256=p6CadqKxifALuKUQW_YCJQSzy4NIHj_NeKUTXY95r3s,835
|
|
4
|
-
sqlspec/exceptions.py,sha256=wfOqLdCmOBpQEkDlMlIAUYItYgTwY5YDmWiHnrBDZBg,2290
|
|
5
|
-
sqlspec/filters.py,sha256=1QeJkY8e4z6VPF0T9qn7xsiDKLKGWtZecg80iZZWdl0,3404
|
|
6
|
-
sqlspec/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
sqlspec/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
sqlspec/types/empty.py,sha256=5iijfAjHHzAVwWlkfea8woUWilHA6nJK_GN1MVedmS0,383
|
|
9
|
-
sqlspec/types/protocols.py,sha256=skczeIQzjvFbgdpnHdGJR_iTTDYJj0M5sef2vJby_es,3093
|
|
10
|
-
sqlspec/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
-
sqlspec/utils/dataclass.py,sha256=swzzYjDgIS0OkmGH5z33P1HFkzvspyamvWGyI25oNGE,4129
|
|
12
|
-
sqlspec-0.1.0.dist-info/METADATA,sha256=INa6CEObNsnM3zXee5nKmiD7FzZ8uIdFUzp8UOpgPGk,1045
|
|
13
|
-
sqlspec-0.1.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
14
|
-
sqlspec-0.1.0.dist-info/RECORD,,
|
|
File without changes
|