Skip to main content
Version: devel

dlt.common.destination.dataset

SupportsDataAccess Objects

class SupportsDataAccess(Protocol)

View source on GitHub

Common data access protocol shared between dbapi cursors and relations

columns_schema

@property
def columns_schema() -> TTableSchemaColumns

View source on GitHub

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]

View source on GitHub

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]

View source on GitHub

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]

View source on GitHub

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]

View source on GitHub

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, ...]]

View source on GitHub

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, ...]]

View source on GitHub

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]

View source on GitHub

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, ...]]

View source on GitHub

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)

View source on GitHub

Protocol for the DBAPI cursor

native_cursor

Cursor implementation native to current destination

execute

def execute(query: AnyStr, *args: Any, **kwargs: Any) -> None

View source on GitHub

Execute a query on the cursor

close

def close() -> None

View source on GitHub

Close the cursor

DBApiCursor Objects

class DBApiCursor(abc.ABC, DBApiCursorProtocol)

View source on GitHub

Protocol for the DBAPI cursor

native_cursor

Cursor implementation native to current destination

execute

def execute(query: AnyStr, *args: Any, **kwargs: Any) -> None

View source on GitHub

Execute a query on the cursor

close

def close() -> None

View source on GitHub

Close the cursor

This demo works on codespaces. Codespaces is a development environment available for free to anyone with a Github account. You'll be asked to fork the demo repository and from there the README guides you with further steps.
The demo uses the Continue VSCode extension.

Off to codespaces!

DHelp

Ask a question

Welcome to "Codex Central", your next-gen help center, driven by OpenAI's GPT-4 model. It's more than just a forum or a FAQ hub – it's a dynamic knowledge base where coders can find AI-assisted solutions to their pressing problems. With GPT-4's powerful comprehension and predictive abilities, Codex Central provides instantaneous issue resolution, insightful debugging, and personalized guidance. Get your code running smoothly with the unparalleled support at Codex Central - coding help reimagined with AI prowess.