Skip to content

Commit ca8b2c7

Browse files
authored
fix: adapter cleanup (#62)
Additional adapter and docstring cleanup
1 parent a75d190 commit ca8b2c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+725
-1516
lines changed

sqlspec/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""SQLSpec: Safe and elegant SQL query building for Python."""
1+
"""SQLSpec: Type-safe SQL query mapper for Python."""
22

33
from sqlspec import adapters, base, builder, core, driver, exceptions, extensions, loader, migrations, typing, utils
44
from sqlspec.__metadata__ import __version__

sqlspec/_sql.py

Lines changed: 21 additions & 110 deletions
Large diffs are not rendered by default.

sqlspec/adapters/adbc/config.py

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""ADBC database configuration using TypedDict for better maintainability."""
1+
"""ADBC database configuration."""
22

33
import logging
44
from contextlib import contextmanager
@@ -60,16 +60,11 @@ class AdbcConnectionParams(TypedDict, total=False):
6060
class AdbcConfig(NoPoolSyncConfig[AdbcConnection, AdbcDriver]):
6161
"""ADBC configuration for Arrow Database Connectivity.
6262
63-
ADBC (Arrow Database Connectivity) provides a unified interface for connecting
64-
to multiple database systems with Arrow-native data transfer.
63+
ADBC provides an interface for connecting to multiple database systems
64+
with Arrow-native data transfer.
6565
66-
This configuration supports:
67-
- Universal driver detection and loading
68-
- Arrow data streaming
69-
- Bulk ingestion operations
70-
- Multiple database backends (PostgreSQL, SQLite, DuckDB, BigQuery, Snowflake, etc.)
71-
- Driver path resolution
72-
- Cloud database integrations
66+
Supports multiple database backends including PostgreSQL, SQLite, DuckDB,
67+
BigQuery, and Snowflake with automatic driver detection and loading.
7368
"""
7469

7570
driver_type: ClassVar[type[AdbcDriver]] = AdbcDriver
@@ -83,7 +78,7 @@ def __init__(
8378
statement_config: Optional[StatementConfig] = None,
8479
driver_features: Optional[dict[str, Any]] = None,
8580
) -> None:
86-
"""Initialize ADBC configuration.
81+
"""Initialize configuration.
8782
8883
Args:
8984
connection_config: Connection configuration parameters
@@ -112,7 +107,7 @@ def __init__(
112107
)
113108

114109
def _resolve_driver_name(self) -> str:
115-
"""Resolve and normalize the ADBC driver name.
110+
"""Resolve and normalize the driver name.
116111
117112
Returns:
118113
The normalized driver connect function path.
@@ -166,7 +161,7 @@ def _resolve_driver_name(self) -> str:
166161
return "adbc_driver_sqlite.dbapi.connect"
167162

168163
def _get_connect_func(self) -> Callable[..., AdbcConnection]:
169-
"""Get the ADBC driver connect function.
164+
"""Get the driver connect function.
170165
171166
Returns:
172167
The driver connect function.
@@ -184,7 +179,7 @@ def _get_connect_func(self) -> Callable[..., AdbcConnection]:
184179
connect_func = import_string(driver_path_with_suffix)
185180
except ImportError as e2:
186181
msg = (
187-
f"Failed to import ADBC connect function from '{driver_path}' or "
182+
f"Failed to import connect function from '{driver_path}' or "
188183
f"'{driver_path_with_suffix}'. Is the driver installed? "
189184
f"Original errors: {e} / {e2}"
190185
)
@@ -197,10 +192,10 @@ def _get_connect_func(self) -> Callable[..., AdbcConnection]:
197192
return connect_func # type: ignore[no-any-return]
198193

199194
def _get_dialect(self) -> "DialectType":
200-
"""Get the SQL dialect type based on the ADBC driver.
195+
"""Get the SQL dialect type based on the driver.
201196
202197
Returns:
203-
The SQL dialect type for the ADBC driver.
198+
The SQL dialect type for the driver.
204199
"""
205200
try:
206201
driver_path = self._resolve_driver_name()
@@ -241,14 +236,14 @@ def _get_parameter_styles(self) -> tuple[tuple[str, ...], str]:
241236
return (("qmark", "numeric"), "qmark")
242237

243238
except Exception:
244-
logger.debug("Error resolving parameter styles for ADBC driver, using defaults")
239+
logger.debug("Error resolving parameter styles, using defaults")
245240
return (("qmark",), "qmark")
246241

247242
def create_connection(self) -> AdbcConnection:
248-
"""Create and return a new ADBC connection using the specified driver.
243+
"""Create and return a new connection using the specified driver.
249244
250245
Returns:
251-
A new ADBC connection instance.
246+
A new connection instance.
252247
253248
Raises:
254249
ImproperConfigurationError: If the connection could not be established.
@@ -260,20 +255,20 @@ def create_connection(self) -> AdbcConnection:
260255
connection = connect_func(**connection_config_dict)
261256
except Exception as e:
262257
driver_name = self.connection_config.get("driver_name", "Unknown")
263-
msg = f"Could not configure ADBC connection using driver '{driver_name}'. Error: {e}"
258+
msg = f"Could not configure connection using driver '{driver_name}'. Error: {e}"
264259
raise ImproperConfigurationError(msg) from e
265260
return connection
266261

267262
@contextmanager
268263
def provide_connection(self, *args: Any, **kwargs: Any) -> "Generator[AdbcConnection, None, None]":
269-
"""Provide an ADBC connection context manager.
264+
"""Provide a connection context manager.
270265
271266
Args:
272267
*args: Additional arguments.
273268
**kwargs: Additional keyword arguments.
274269
275270
Yields:
276-
An ADBC connection instance.
271+
A connection instance.
277272
"""
278273
connection = self.create_connection()
279274
try:
@@ -284,7 +279,7 @@ def provide_connection(self, *args: Any, **kwargs: Any) -> "Generator[AdbcConnec
284279
def provide_session(
285280
self, *args: Any, statement_config: "Optional[StatementConfig]" = None, **kwargs: Any
286281
) -> "AbstractContextManager[AdbcDriver]":
287-
"""Provide an ADBC driver session context manager.
282+
"""Provide a driver session context manager.
288283
289284
Args:
290285
*args: Additional arguments.
@@ -349,10 +344,7 @@ def _get_connection_config_dict(self) -> dict[str, Any]:
349344
return config
350345

351346
def get_signature_namespace(self) -> "dict[str, type[Any]]":
352-
"""Get the signature namespace for ADBC types.
353-
354-
This provides all ADBC-specific types that Litestar needs to recognize
355-
to avoid serialization attempts.
347+
"""Get the signature namespace for types.
356348
357349
Returns:
358350
Dictionary mapping type names to types.

0 commit comments

Comments
 (0)