Skip to main content
Version: 1.33.0 (latest)

dlt.destinations.impl.duckdb.sql_client

HAS_TO_ARROW_API​

duckdb 1.5 added to_arrow_* on connections and relations and deprecated fetch_arrow_*

HAS_SUBMIT​

duckdb 2 runs one statement to rows, an Arrow table or an Arrow stream with private _submit

DuckDB1CursorImpl Objects​

class DuckDB1CursorImpl(DBApiCursorImpl)

View source on GitHub

Reads the DB-API result of a duckdb connection, used before duckdb 2

native_cursor​

type: ignore

vector_size​

vector size is 2048

from_query​

@classmethod
def from_query(cls,
conn: duckdb.DuckDBPyConnection,
query: str,
params: Any = None) -> "DuckDB1CursorImpl"

View source on GitHub

Runs query with params on conn and returns a cursor over its result

DuckDB2CursorImpl Objects​

class DuckDB2CursorImpl(DuckDB1CursorImpl)

View source on GitHub

Runs each query once and reads Arrow on duckdb 2 without the copy of a DB-API result

DuckDbSqlClient Objects​

class DuckDbSqlClient(SqlClientBase[duckdb.DuckDBPyConnection], DBTransaction,
WithAttach)

View source on GitHub

SECRET_REFRESH_MARGIN​

Token lifetime left when the client creates a secret with a frozen token again.

warn_if_catalog_equals_dataset_name​

def warn_if_catalog_equals_dataset_name() -> None

View source on GitHub

Checks if the DuckDB connection's current catalog equals the dataset name (schema).

list_secrets​

@raise_database_error
def list_secrets() -> Sequence[str]

View source on GitHub

List secrets that belong to this dataset

use_dataset​

def use_dataset() -> None

View source on GitHub

Makes duckdb schema corresponding to dataset_name the default

WithTableScanners Objects​

class WithTableScanners(DuckDbSqlClient, WithSchemas)

View source on GitHub

memory_db​

Internally created in-mem database in case external is not provided. It is never closed: closing would kill the connections handed out of it, and duckdb frees the database when the last of them is gone

__init__​

def __init__(remote_client: JobClientBase,
dataset_name: str,
cache_db: DuckDbCredentials = None,
persist_secrets: bool = False) -> None

View source on GitHub

Allows to maps data in tables accessed via remote_client as VIEWs in duckdb database. Creates in memory "cache" database by default or allows for external database via "cache_db". Will attempt to create views lazily by parsing SQL queries, identifying tables and adding views before execution.

should_replace_view​

@abstractmethod
def should_replace_view(view_name: str,
table_schema: PreparedTableSchema) -> bool

View source on GitHub

Tells if view view_name should be replaced

create_view_select​

@abstractmethod
def create_view_select(table_schema: PreparedTableSchema,
schema: Schema = None) -> Optional[Tuple[str, str]]

View source on GitHub

Build the SELECT SQL for a view backed by destination data.

Returns (data_location, select_sql) or None when the view cannot be created (e.g. unsupported file format).

can_create_view​

@abstractmethod
def can_create_view(table_schema: PreparedTableSchema) -> bool

View source on GitHub

Tells if a view for a table table_schema can be created

set_schemas​

def set_schemas(schemas: Sequence[Schema]) -> None

View source on GitHub

Register schemas for multi-schema view creation.

create_views_for_tables​

@raise_database_error
def create_views_for_tables(tables: Dict[str, str]) -> None

View source on GitHub

Add the required tables as views to the duckdb in memory instance.

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.