dlt.common.destination.dataset
SupportsDataAccess Objects
class SupportsDataAccess(Protocol)
Common data access protocol shared between dbapi cursors and relations
columns_schema
@property
def columns_schema() -> TTableSchemaColumns
Returns the expected columns schema for the result of the relation. Column types are discovered with sql glot query analysis and lineage. dlt hints for columns are kept in some cases. Refere to <docs-page> for more details.
df
def df(chunk_size: Optional[int] = None) -> Optional[DataFrame]
Fetches the results as arrow table. Uses the native pandas implementation of the destination client cursor if available.
Arguments:
chunk_size
Optional[int] - The number of rows to fetch for this call. Defaults to None which will fetch all rows.
Returns:
Optional[DataFrame]
- A data frame with query results.
arrow
def arrow(chunk_size: Optional[int] = None) -> Optional[ArrowTable]
Fetches the results as arrow table. Uses the native arrow implementation of the destination client cursor if available.
Arguments:
chunk_size
Optional[int] - The number of rows to fetch for this call. Defaults to None which will fetch all rows.
Returns:
Optional[ArrowTable]
- An arrow table with query results.
iter_df
def iter_df(chunk_size: int) -> Generator[DataFrame, None, None]
Iterates over data frames of 'chunk_size' items. Uses the native pandas implementation of the destination client cursor if available.
Arguments:
chunk_size
int - The number of rows to fetch for each iteration.
Returns:
Generator[DataFrame, None, None]: A generator of data frames with query results.
iter_arrow
def iter_arrow(chunk_size: int) -> Generator[ArrowTable, None, None]
Iterates over arrow tables of 'chunk_size' items. Uses the native arrow implementation of the destination client cursor if available.
Arguments:
chunk_size
int - The number of rows to fetch for each iteration.
Returns:
Generator[ArrowTable, None, None]: A generator of arrow tables with query results.
fetchall
def fetchall() -> list[tuple[Any, ...]]
Fetches all items as a list of python tuples. Uses the native dbapi fetchall implementation of the destination client cursor.
Returns:
list[tuple[Any, ...]]: A list of python tuples w
fetchmany
def fetchmany(chunk_size: int) -> list[tuple[Any, ...]]
Fetches the first 'chunk_size' items as a list of python tuples. Uses the native dbapi fetchmany implementation of the destination client cursor.
Arguments:
chunk_size
int - The number of rows to fetch for this call.
Returns:
list[tuple[Any, ...]]: A list of python tuples with query results.
iter_fetch
def iter_fetch(chunk_size: int) -> Generator[list[tuple[Any, ...]], Any, Any]
Iterates in lists of Python tuples in 'chunk_size' chunks. Uses the native dbapi fetchmany implementation of the destination client cursor.
Arguments:
chunk_size
int - The number of rows to fetch for each iteration.
Returns:
Generator[list[tuple[Any, ...]], Any, Any]: A generator of lists of python tuples with query results.
fetchone
def fetchone() -> Optional[tuple[Any, ...]]
Fetches the first item as a python tuple. Uses the native dbapi fetchone implementation of the destination client cursor.
Returns:
Optional[tuple[Any, ...]]: A python tuple with the first item of the query results.
DBApiCursorProtocol Objects
class DBApiCursorProtocol(SupportsDataAccess, Protocol)
Protocol for the DBAPI cursor
native_cursor
Cursor implementation native to current destination
execute
def execute(query: AnyStr, *args: Any, **kwargs: Any) -> None
Execute a query on the cursor
close
def close() -> None
Close the cursor
DBApiCursor Objects
class DBApiCursor(abc.ABC, DBApiCursorProtocol)
Protocol for the DBAPI cursor
native_cursor
Cursor implementation native to current destination
execute
def execute(query: AnyStr, *args: Any, **kwargs: Any) -> None
Execute a query on the cursor
close
def close() -> None
Close the cursor