Skip to main content
Version: devel

dlt.destinations.impl.duckdb.sql_client

DuckDBDBApiCursorImpl Objects

class DuckDBDBApiCursorImpl(DBApiCursorImpl)

View source on GitHub

Use native duckdb data frame support if available

native_cursor

type: ignore

vector_size

vector size is 2048

DuckDbSqlClient Objects

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

View source on GitHub

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

__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.

When a table name appears in multiple schemas, views are grouped by physical data location. Co-located schemas get their columns merged into a single SELECT; different locations are combined with UNION ALL BY NAME.

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.