sqlspec 0.1.1__py3-none-any.whl → 0.4.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.

Files changed (42) hide show
  1. sqlspec/__metadata__.py +1 -1
  2. sqlspec/_serialization.py +1 -1
  3. sqlspec/_typing.py +138 -0
  4. sqlspec/adapters/adbc/config.py +52 -0
  5. sqlspec/adapters/aiosqlite/__init__.py +3 -0
  6. sqlspec/adapters/aiosqlite/config.py +95 -0
  7. sqlspec/adapters/asyncmy/__init__.py +3 -0
  8. sqlspec/adapters/asyncmy/config.py +176 -0
  9. sqlspec/adapters/asyncpg/__init__.py +0 -0
  10. sqlspec/adapters/asyncpg/config.py +145 -0
  11. sqlspec/adapters/duckdb/__init__.py +0 -0
  12. sqlspec/adapters/duckdb/config.py +201 -0
  13. sqlspec/adapters/oracledb/__init__.py +13 -0
  14. sqlspec/adapters/oracledb/config/__init__.py +9 -0
  15. sqlspec/adapters/oracledb/config/_asyncio.py +95 -0
  16. sqlspec/adapters/oracledb/config/_common.py +151 -0
  17. sqlspec/adapters/oracledb/config/_sync.py +95 -0
  18. sqlspec/adapters/psycopg/__init__.py +0 -0
  19. sqlspec/adapters/psycopg/config/__init__.py +9 -0
  20. sqlspec/adapters/psycopg/config/_async.py +75 -0
  21. sqlspec/adapters/psycopg/config/_common.py +73 -0
  22. sqlspec/adapters/psycopg/config/_sync.py +75 -0
  23. sqlspec/adapters/sqlite/__init__.py +0 -0
  24. sqlspec/adapters/sqlite/config.py +92 -0
  25. sqlspec/config.py +16 -0
  26. sqlspec/exceptions.py +29 -0
  27. sqlspec/extensions/__init__.py +0 -0
  28. sqlspec/extensions/litestar/__init__.py +0 -0
  29. sqlspec/extensions/litestar/plugin.py +34 -0
  30. sqlspec/filters.py +35 -28
  31. sqlspec/typing.py +415 -0
  32. sqlspec-0.4.0.dist-info/METADATA +84 -0
  33. sqlspec-0.4.0.dist-info/RECORD +39 -0
  34. {sqlspec-0.1.1.dist-info → sqlspec-0.4.0.dist-info}/WHEEL +1 -1
  35. sqlspec-0.4.0.dist-info/licenses/NOTICE +29 -0
  36. sqlspec/types/empty.py +0 -18
  37. sqlspec/types/protocols.py +0 -117
  38. sqlspec/utils/dataclass.py +0 -130
  39. sqlspec-0.1.1.dist-info/METADATA +0 -25
  40. sqlspec-0.1.1.dist-info/RECORD +0 -14
  41. /sqlspec/{types → adapters}/__init__.py +0 -0
  42. /sqlspec/{utils → adapters/adbc}/__init__.py +0 -0
@@ -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: ...
@@ -1,130 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from dataclasses import Field, fields
4
- from typing import TYPE_CHECKING, TypeGuard
5
-
6
- from sqlspec.types.empty import Empty
7
-
8
- if TYPE_CHECKING:
9
- from collections.abc import Iterable
10
- from collections.abc import Set as AbstractSet
11
- from typing import Any
12
-
13
- from sqlspec.types.protocols import DataclassProtocol
14
-
15
- __all__ = (
16
- "extract_dataclass_fields",
17
- "extract_dataclass_items",
18
- "is_dataclass_instance",
19
- "simple_asdict",
20
- )
21
-
22
-
23
- def is_dataclass_instance(obj: Any) -> TypeGuard[DataclassProtocol]:
24
- """Check if an object is a dataclass instance.
25
-
26
- Args:
27
- obj: An object to check.
28
-
29
- Returns:
30
- True if the object is a dataclass instance.
31
- """
32
- return hasattr(type(obj), "__dataclass_fields__")
33
-
34
-
35
- def extract_dataclass_fields(
36
- dt: DataclassProtocol,
37
- exclude_none: bool = False,
38
- exclude_empty: bool = False,
39
- include: AbstractSet[str] | None = None,
40
- exclude: AbstractSet[str] | None = None,
41
- ) -> tuple[Field[Any], ...]:
42
- """Extract dataclass fields.
43
-
44
- Args:
45
- dt: A dataclass instance.
46
- exclude_none: Whether to exclude None values.
47
- exclude_empty: Whether to exclude Empty values.
48
- include: An iterable of fields to include.
49
- exclude: An iterable of fields to exclude.
50
-
51
-
52
- Returns:
53
- A tuple of dataclass fields.
54
- """
55
- include = include or set()
56
- exclude = exclude or set()
57
-
58
- if common := (include & exclude):
59
- msg = f"Fields {common} are both included and excluded."
60
- raise ValueError(msg)
61
-
62
- dataclass_fields: Iterable[Field[Any]] = fields(dt)
63
- if exclude_none:
64
- dataclass_fields = (field for field in dataclass_fields if getattr(dt, field.name) is not None)
65
- if exclude_empty:
66
- dataclass_fields = (field for field in dataclass_fields if getattr(dt, field.name) is not Empty)
67
- if include:
68
- dataclass_fields = (field for field in dataclass_fields if field.name in include)
69
- if exclude:
70
- dataclass_fields = (field for field in dataclass_fields if field.name not in exclude)
71
-
72
- return tuple(dataclass_fields)
73
-
74
-
75
- def extract_dataclass_items(
76
- dt: DataclassProtocol,
77
- exclude_none: bool = False,
78
- exclude_empty: bool = False,
79
- include: AbstractSet[str] | None = None,
80
- exclude: AbstractSet[str] | None = None,
81
- ) -> tuple[tuple[str, Any], ...]:
82
- """Extract dataclass name, value pairs.
83
-
84
- Unlike the 'asdict' method exports by the stdlib, this function does not pickle values.
85
-
86
- Args:
87
- dt: A dataclass instance.
88
- exclude_none: Whether to exclude None values.
89
- exclude_empty: Whether to exclude Empty values.
90
- include: An iterable of fields to include.
91
- exclude: An iterable of fields to exclude.
92
-
93
- Returns:
94
- A tuple of key/value pairs.
95
- """
96
- dataclass_fields = extract_dataclass_fields(dt, exclude_none, exclude_empty, include, exclude)
97
- return tuple((field.name, getattr(dt, field.name)) for field in dataclass_fields)
98
-
99
-
100
- def simple_asdict(
101
- obj: DataclassProtocol,
102
- exclude_none: bool = False,
103
- exclude_empty: bool = False,
104
- convert_nested: bool = True,
105
- exclude: set[str] | None = None,
106
- ) -> dict[str, Any]:
107
- """Convert a dataclass to a dictionary.
108
-
109
- This method has important differences to the standard library version:
110
- - it does not deepcopy values
111
- - it does not recurse into collections
112
-
113
- Args:
114
- obj: A dataclass instance.
115
- exclude_none: Whether to exclude None values.
116
- exclude_empty: Whether to exclude Empty values.
117
- convert_nested: Whether to recursively convert nested dataclasses.
118
- exclude: An iterable of fields to exclude.
119
-
120
- Returns:
121
- A dictionary of key/value pairs.
122
- """
123
- ret = {}
124
- for field in extract_dataclass_fields(obj, exclude_none, exclude_empty, exclude=exclude):
125
- value = getattr(obj, field.name)
126
- if is_dataclass_instance(value) and convert_nested:
127
- ret[field.name] = simple_asdict(value, exclude_none, exclude_empty)
128
- else:
129
- ret[field.name] = getattr(obj, field.name)
130
- return ret
@@ -1,25 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: sqlspec
3
- Version: 0.1.1
4
- Summary: SQL Experiments 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 Experiments in Python
@@ -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.1.dist-info/METADATA,sha256=RqCSsr4Gm6sTqQE1KaRWuk_QYlEJRMgIoOuLNfzSTV4,1045
13
- sqlspec-0.1.1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
14
- sqlspec-0.1.1.dist-info/RECORD,,
File without changes
File without changes