class duckdb.BinaryValue(object: Any)

Bases: Value

class duckdb.BinderException

Bases: ProgrammingError

class duckdb.BitValue(object: Any)

Bases: Value

class duckdb.BlobValue(object: Any)

Bases: Value

class duckdb.BooleanValue(object: Any)

Bases: Value

class duckdb.CSVLineTerminator

Bases: pybind11_object

Members:

LINE_FEED

CARRIAGE_RETURN_LINE_FEED

property name
duckdb.CaseExpression(condition: duckdb.duckdb.Expression, value: duckdb.duckdb.Expression) duckdb.duckdb.Expression
class duckdb.CatalogException

Bases: ProgrammingError

duckdb.CoalesceOperator(*args) duckdb.duckdb.Expression
duckdb.ColumnExpression(*args) duckdb.duckdb.Expression

Create a column reference from the provided column name

class duckdb.ConnectionException

Bases: OperationalError

duckdb.ConstantExpression(value: object) duckdb.duckdb.Expression

Create a constant expression from the provided value

class duckdb.ConstraintException

Bases: IntegrityError

class duckdb.ConversionException

Bases: DataError

class duckdb.DataError

Bases: DatabaseError

class duckdb.DateValue(object: Any)

Bases: Value

class duckdb.DecimalValue(object: Any, width: int, scale: int)

Bases: Value

duckdb.DefaultExpression() duckdb.duckdb.Expression
class duckdb.DoubleValue(object: Any)

Bases: Value

class duckdb.DuckDBPyConnection

Bases: pybind11_object

append(self: duckdb.duckdb.DuckDBPyConnection, table_name: str, df: pandas.DataFrame, *, by_name: bool = False) duckdb.duckdb.DuckDBPyConnection

Append the passed DataFrame to the named table

array_type(self: duckdb.duckdb.DuckDBPyConnection, type: duckdb.duckdb.typing.DuckDBPyType, size: int) duckdb.duckdb.typing.DuckDBPyType

Create an array type object of ‘type’

arrow(self: duckdb.duckdb.DuckDBPyConnection, rows_per_batch: int = 1000000) pyarrow.lib.Table

Fetch a result as Arrow table following execute()

begin(self: duckdb.duckdb.DuckDBPyConnection) duckdb.duckdb.DuckDBPyConnection

Start a new transaction

checkpoint(self: duckdb.duckdb.DuckDBPyConnection) duckdb.duckdb.DuckDBPyConnection

Synchronizes data in the write-ahead log (WAL) to the database data file (no-op for in-memory connections)

close(self: duckdb.duckdb.DuckDBPyConnection) None

Close the connection

commit(self: duckdb.duckdb.DuckDBPyConnection) duckdb.duckdb.DuckDBPyConnection

Commit changes performed within a transaction

create_function(self: duckdb.duckdb.DuckDBPyConnection, name: str, function: Callable, parameters: object = None, return_type: duckdb.duckdb.typing.DuckDBPyType = None, *, type: duckdb.duckdb.functional.PythonUDFType = <PythonUDFType.NATIVE: 0>, null_handling: duckdb.duckdb.functional.FunctionNullHandling = <FunctionNullHandling.DEFAULT: 0>, exception_handling: duckdb.duckdb.PythonExceptionHandling = <PythonExceptionHandling.DEFAULT: 0>, side_effects: bool = False) duckdb.duckdb.DuckDBPyConnection

Create a DuckDB function out of the passing in Python function so it can be used in queries

cursor(self: duckdb.duckdb.DuckDBPyConnection) duckdb.duckdb.DuckDBPyConnection

Create a duplicate of the current connection

decimal_type(self: duckdb.duckdb.DuckDBPyConnection, width: int, scale: int) duckdb.duckdb.typing.DuckDBPyType

Create a decimal type with ‘width’ and ‘scale’

property description

Get result set attributes, mainly column names

df(self: duckdb.duckdb.DuckDBPyConnection, *, date_as_object: bool = False) pandas.DataFrame

Fetch a result as DataFrame following execute()

dtype(self: duckdb.duckdb.DuckDBPyConnection, type_str: str) duckdb.duckdb.typing.DuckDBPyType

Create a type object by parsing the ‘type_str’ string

duplicate(self: duckdb.duckdb.DuckDBPyConnection) duckdb.duckdb.DuckDBPyConnection

Create a duplicate of the current connection

enum_type(self: duckdb.duckdb.DuckDBPyConnection, name: str, type: duckdb.duckdb.typing.DuckDBPyType, values: list) duckdb.duckdb.typing.DuckDBPyType

Create an enum type of underlying ‘type’, consisting of the list of ‘values’

execute(self: duckdb.duckdb.DuckDBPyConnection, query: object, parameters: object = None) duckdb.duckdb.DuckDBPyConnection

Execute the given SQL query, optionally using prepared statements with parameters set

executemany(self: duckdb.duckdb.DuckDBPyConnection, query: object, parameters: object = None) duckdb.duckdb.DuckDBPyConnection

Execute the given prepared statement multiple times using the list of parameter sets in parameters

extract_statements(self: duckdb.duckdb.DuckDBPyConnection, query: str) list

Parse the query string and extract the Statement object(s) produced

fetch_arrow_table(self: duckdb.duckdb.DuckDBPyConnection, rows_per_batch: int = 1000000) pyarrow.lib.Table

Fetch a result as Arrow table following execute()

fetch_df(self: duckdb.duckdb.DuckDBPyConnection, *, date_as_object: bool = False) pandas.DataFrame

Fetch a result as DataFrame following execute()

fetch_df_chunk(self: duckdb.duckdb.DuckDBPyConnection, vectors_per_chunk: int = 1, *, date_as_object: bool = False) pandas.DataFrame

Fetch a chunk of the result as DataFrame following execute()

fetch_record_batch(self: duckdb.duckdb.DuckDBPyConnection, rows_per_batch: int = 1000000) pyarrow.lib.RecordBatchReader

Fetch an Arrow RecordBatchReader following execute()

fetchall(self: duckdb.duckdb.DuckDBPyConnection) list

Fetch all rows from a result following execute

fetchdf(self: duckdb.duckdb.DuckDBPyConnection, *, date_as_object: bool = False) pandas.DataFrame

Fetch a result as DataFrame following execute()

fetchmany(self: duckdb.duckdb.DuckDBPyConnection, size: int = 1) list

Fetch the next set of rows from a result following execute

fetchnumpy(self: duckdb.duckdb.DuckDBPyConnection) dict

Fetch a result as list of NumPy arrays following execute

fetchone(self: duckdb.duckdb.DuckDBPyConnection) Optional[tuple]

Fetch a single row from a result following execute

filesystem_is_registered(self: duckdb.duckdb.DuckDBPyConnection, name: str) bool

Check if a filesystem with the provided name is currently registered

from_arrow(self: duckdb.duckdb.DuckDBPyConnection, arrow_object: object) duckdb.duckdb.DuckDBPyRelation

Create a relation object from an Arrow object

from_csv_auto(self: duckdb.duckdb.DuckDBPyConnection, path_or_buffer: object, **kwargs) duckdb.duckdb.DuckDBPyRelation

Create a relation object from the CSV file in ‘name’

from_df(self: duckdb.duckdb.DuckDBPyConnection, df: pandas.DataFrame) duckdb.duckdb.DuckDBPyRelation

Create a relation object from the DataFrame in df

from_parquet(*args, **kwargs)

Overloaded function.

  1. from_parquet(self: duckdb.duckdb.DuckDBPyConnection, file_glob: str, binary_as_string: bool = False, *, file_row_number: bool = False, filename: bool = False, hive_partitioning: bool = False, union_by_name: bool = False, compression: object = None) -> duckdb.duckdb.DuckDBPyRelation

Create a relation object from the Parquet files in file_glob

  1. from_parquet(self: duckdb.duckdb.DuckDBPyConnection, file_globs: list[str], binary_as_string: bool = False, *, file_row_number: bool = False, filename: bool = False, hive_partitioning: bool = False, union_by_name: bool = False, compression: object = None) -> duckdb.duckdb.DuckDBPyRelation

Create a relation object from the Parquet files in file_globs

from_query(self: duckdb.duckdb.DuckDBPyConnection, query: object, *, alias: str = '', params: object = None) duckdb.duckdb.DuckDBPyRelation

Run a SQL query. If it is a SELECT statement, create a relation object from the given SQL query, otherwise run the query as-is.

get_table_names(self: duckdb.duckdb.DuckDBPyConnection, query: str) set[str]

Extract the required table names from a query

install_extension(self: duckdb.duckdb.DuckDBPyConnection, extension: str, *, force_install: bool = False, repository: object = None, repository_url: object = None, version: object = None) None

Install an extension by name, with an optional version and/or repository to get the extension from

interrupt(self: duckdb.duckdb.DuckDBPyConnection) None

Interrupt pending operations

list_filesystems(self: duckdb.duckdb.DuckDBPyConnection) list

List registered filesystems, including builtin ones

list_type(self: duckdb.duckdb.DuckDBPyConnection, type: duckdb.duckdb.typing.DuckDBPyType) duckdb.duckdb.typing.DuckDBPyType

Create a list type object of ‘type’

load_extension(self: duckdb.duckdb.DuckDBPyConnection, extension: str) None

Load an installed extension

map_type(self: duckdb.duckdb.DuckDBPyConnection, key: duckdb.duckdb.typing.DuckDBPyType, value: duckdb.duckdb.typing.DuckDBPyType) duckdb.duckdb.typing.DuckDBPyType

Create a map type object from ‘key_type’ and ‘value_type’

pl(self: duckdb.duckdb.DuckDBPyConnection, rows_per_batch: int = 1000000) duckdb::PolarsDataFrame

Fetch a result as Polars DataFrame following execute()

query(self: duckdb.duckdb.DuckDBPyConnection, query: object, *, alias: str = '', params: object = None) duckdb.duckdb.DuckDBPyRelation

Run a SQL query. If it is a SELECT statement, create a relation object from the given SQL query, otherwise run the query as-is.

read_csv(self: duckdb.duckdb.DuckDBPyConnection, path_or_buffer: object, **kwargs) duckdb.duckdb.DuckDBPyRelation

Create a relation object from the CSV file in ‘name’

read_json(self: duckdb.duckdb.DuckDBPyConnection, path_or_buffer: object, *, columns: Optional[object] = None, sample_size: Optional[object] = None, maximum_depth: Optional[object] = None, records: Optional[str] = None, format: Optional[str] = None, date_format: Optional[object] = None, timestamp_format: Optional[object] = None, compression: Optional[object] = None, maximum_object_size: Optional[object] = None, ignore_errors: Optional[object] = None, convert_strings_to_integers: Optional[object] = None, field_appearance_threshold: Optional[object] = None, map_inference_threshold: Optional[object] = None, maximum_sample_files: Optional[object] = None, filename: Optional[object] = None, hive_partitioning: Optional[object] = None, union_by_name: Optional[object] = None, hive_types: Optional[object] = None, hive_types_autocast: Optional[object] = None) duckdb.duckdb.DuckDBPyRelation

Create a relation object from the JSON file in ‘name’

read_parquet(*args, **kwargs)

Overloaded function.

  1. read_parquet(self: duckdb.duckdb.DuckDBPyConnection, file_glob: str, binary_as_string: bool = False, *, file_row_number: bool = False, filename: bool = False, hive_partitioning: bool = False, union_by_name: bool = False, compression: object = None) -> duckdb.duckdb.DuckDBPyRelation

Create a relation object from the Parquet files in file_glob

  1. read_parquet(self: duckdb.duckdb.DuckDBPyConnection, file_globs: list[str], binary_as_string: bool = False, *, file_row_number: bool = False, filename: bool = False, hive_partitioning: bool = False, union_by_name: bool = False, compression: object = None) -> duckdb.duckdb.DuckDBPyRelation

Create a relation object from the Parquet files in file_globs

register(self: duckdb.duckdb.DuckDBPyConnection, view_name: str, python_object: object) duckdb.duckdb.DuckDBPyConnection

Register the passed Python Object value for querying with a view

register_filesystem(self: duckdb.duckdb.DuckDBPyConnection, filesystem: fsspec.AbstractFileSystem) None

Register a fsspec compliant filesystem

remove_function(self: duckdb.duckdb.DuckDBPyConnection, name: str) duckdb.duckdb.DuckDBPyConnection

Remove a previously created function

rollback(self: duckdb.duckdb.DuckDBPyConnection) duckdb.duckdb.DuckDBPyConnection

Roll back changes performed within a transaction

row_type(self: duckdb.duckdb.DuckDBPyConnection, fields: object) duckdb.duckdb.typing.DuckDBPyType

Create a struct type object from ‘fields’

property rowcount

Get result set row count

sql(self: duckdb.duckdb.DuckDBPyConnection, query: object, *, alias: str = '', params: object = None) duckdb.duckdb.DuckDBPyRelation

Run a SQL query. If it is a SELECT statement, create a relation object from the given SQL query, otherwise run the query as-is.

sqltype(self: duckdb.duckdb.DuckDBPyConnection, type_str: str) duckdb.duckdb.typing.DuckDBPyType

Create a type object by parsing the ‘type_str’ string

string_type(self: duckdb.duckdb.DuckDBPyConnection, collation: str = '') duckdb.duckdb.typing.DuckDBPyType

Create a string type with an optional collation

struct_type(self: duckdb.duckdb.DuckDBPyConnection, fields: object) duckdb.duckdb.typing.DuckDBPyType

Create a struct type object from ‘fields’

table(self: duckdb.duckdb.DuckDBPyConnection, table_name: str) duckdb.duckdb.DuckDBPyRelation

Create a relation object for the named table

table_function(self: duckdb.duckdb.DuckDBPyConnection, name: str, parameters: object = None) duckdb.duckdb.DuckDBPyRelation

Create a relation object from the named table function with given parameters

tf(self: duckdb.duckdb.DuckDBPyConnection) dict

Fetch a result as dict of TensorFlow Tensors following execute()

torch(self: duckdb.duckdb.DuckDBPyConnection) dict

Fetch a result as dict of PyTorch Tensors following execute()

type(self: duckdb.duckdb.DuckDBPyConnection, type_str: str) duckdb.duckdb.typing.DuckDBPyType

Create a type object by parsing the ‘type_str’ string

union_type(self: duckdb.duckdb.DuckDBPyConnection, members: object) duckdb.duckdb.typing.DuckDBPyType

Create a union type object from ‘members’

unregister(self: duckdb.duckdb.DuckDBPyConnection, view_name: str) duckdb.duckdb.DuckDBPyConnection

Unregister the view name

unregister_filesystem(self: duckdb.duckdb.DuckDBPyConnection, name: str) None

Unregister a filesystem

values(self: duckdb.duckdb.DuckDBPyConnection, *args) duckdb.duckdb.DuckDBPyRelation

Create a relation object from the passed values

view(self: duckdb.duckdb.DuckDBPyConnection, view_name: str) duckdb.duckdb.DuckDBPyRelation

Create a relation object for the named view

class duckdb.DuckDBPyRelation

Bases: pybind11_object

Detailed examples can be found at Relational API page.

aggregate(self: duckdb.duckdb.DuckDBPyRelation, aggr_expr: object, group_expr: str = '') duckdb.duckdb.DuckDBPyRelation

Compute the aggregate aggr_expr by the optional groups group_expr on the relation

Detailed examples can be found at Relational API page.

alias

Get the name of the current alias

Detailed examples can be found at Relational API page.

any_value(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Returns the first non-null value from a given column

Detailed examples can be found at Relational API page.

apply(self: duckdb.duckdb.DuckDBPyRelation, function_name: str, function_aggr: str, group_expr: str = '', function_parameter: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Compute the function of a single column or a list of columns by the optional groups on the relation

Detailed examples can be found at Relational API page.

arg_max(self: duckdb.duckdb.DuckDBPyRelation, arg_column: str, value_column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Finds the row with the maximum value for a value column and returns the value of that row for an argument column

Detailed examples can be found at Relational API page.

arg_min(self: duckdb.duckdb.DuckDBPyRelation, arg_column: str, value_column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Finds the row with the minimum value for a value column and returns the value of that row for an argument column

Detailed examples can be found at Relational API page.

arrow(self: duckdb.duckdb.DuckDBPyRelation, batch_size: int = 1000000) pyarrow.lib.Table

Execute and fetch all rows as an Arrow Table

Detailed examples can be found at Relational API page.

avg(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the average on a given column

Detailed examples can be found at Relational API page.

bit_and(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the bitwise AND of all bits present in a given column

Detailed examples can be found at Relational API page.

bit_or(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the bitwise OR of all bits present in a given column

Detailed examples can be found at Relational API page.

bit_xor(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the bitwise XOR of all bits present in a given column

Detailed examples can be found at Relational API page.

bitstring_agg(self: duckdb.duckdb.DuckDBPyRelation, column: str, min: Optional[object] = None, max: Optional[object] = None, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes a bitstring with bits set for each distinct value in a given column

Detailed examples can be found at Relational API page.

bool_and(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the logical AND of all values present in a given column

Detailed examples can be found at Relational API page.

bool_or(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the logical OR of all values present in a given column

Detailed examples can be found at Relational API page.

close(self: duckdb.duckdb.DuckDBPyRelation) None

Closes the result

Detailed examples can be found at Relational API page.

columns

Return a list containing the names of the columns of the relation.

Detailed examples can be found at Relational API page.

count(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the number of elements present in a given column

Detailed examples can be found at Relational API page.

create(self: duckdb.duckdb.DuckDBPyRelation, table_name: str) None

Creates a new table named table_name with the contents of the relation object

Detailed examples can be found at Relational API page.

create_view(self: duckdb.duckdb.DuckDBPyRelation, view_name: str, replace: bool = True) duckdb.duckdb.DuckDBPyRelation

Creates a view named view_name that refers to the relation object

Detailed examples can be found at Relational API page.

cross(self: duckdb.duckdb.DuckDBPyRelation, other_rel: duckdb.duckdb.DuckDBPyRelation) duckdb.duckdb.DuckDBPyRelation

Create cross/cartesian product of two relational objects

Detailed examples can be found at Relational API page.

cume_dist(self: duckdb.duckdb.DuckDBPyRelation, window_spec: str, projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the cumulative distribution within the partition

Detailed examples can be found at Relational API page.

dense_rank(self: duckdb.duckdb.DuckDBPyRelation, window_spec: str, projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the dense rank within the partition

Detailed examples can be found at Relational API page.

describe(self: duckdb.duckdb.DuckDBPyRelation) duckdb.duckdb.DuckDBPyRelation

Gives basic statistics (e.g., min, max) and if NULL exists for each column of the relation.

Detailed examples can be found at Relational API page.

description

Return the description of the result

Detailed examples can be found at Relational API page.

df(self: duckdb.duckdb.DuckDBPyRelation, *, date_as_object: bool = False) pandas.DataFrame

Execute and fetch all rows as a pandas DataFrame

Detailed examples can be found at Relational API page.

distinct(self: duckdb.duckdb.DuckDBPyRelation) duckdb.duckdb.DuckDBPyRelation

Retrieve distinct rows from this relation object

Detailed examples can be found at Relational API page.

dtypes

Return a list containing the types of the columns of the relation.

Detailed examples can be found at Relational API page.

except_(self: duckdb.duckdb.DuckDBPyRelation, other_rel: duckdb.duckdb.DuckDBPyRelation) duckdb.duckdb.DuckDBPyRelation

Create the set except of this relation object with another relation object in other_rel

Detailed examples can be found at Relational API page.

execute(self: duckdb.duckdb.DuckDBPyRelation) duckdb.duckdb.DuckDBPyRelation

Transform the relation into a result set

Detailed examples can be found at Relational API page.

explain(self: duckdb.duckdb.DuckDBPyRelation, type: duckdb.duckdb.ExplainType = 'standard') str
Detailed examples can be found at Relational API page.

favg(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the average of all values present in a given column using a more accurate floating point summation (Kahan Sum)

Detailed examples can be found at Relational API page.

fetch_arrow_reader(self: duckdb.duckdb.DuckDBPyRelation, batch_size: int = 1000000) pyarrow.lib.RecordBatchReader

Execute and return an Arrow Record Batch Reader that yields all rows

Detailed examples can be found at Relational API page.

fetch_arrow_table(self: duckdb.duckdb.DuckDBPyRelation, batch_size: int = 1000000) pyarrow.lib.Table

Execute and fetch all rows as an Arrow Table

Detailed examples can be found at Relational API page.

fetch_df_chunk(self: duckdb.duckdb.DuckDBPyRelation, vectors_per_chunk: int = 1, *, date_as_object: bool = False) pandas.DataFrame

Execute and fetch a chunk of the rows

Detailed examples can be found at Relational API page.

fetchall(self: duckdb.duckdb.DuckDBPyRelation) list

Execute and fetch all rows as a list of tuples

Detailed examples can be found at Relational API page.

fetchdf(self: duckdb.duckdb.DuckDBPyRelation, *, date_as_object: bool = False) pandas.DataFrame

Execute and fetch all rows as a pandas DataFrame

Detailed examples can be found at Relational API page.

fetchmany(self: duckdb.duckdb.DuckDBPyRelation, size: int = 1) list

Execute and fetch the next set of rows as a list of tuples

Detailed examples can be found at Relational API page.

fetchnumpy(self: duckdb.duckdb.DuckDBPyRelation) dict

Execute and fetch all rows as a Python dict mapping each column to one numpy arrays

Detailed examples can be found at Relational API page.

fetchone(self: duckdb.duckdb.DuckDBPyRelation) Optional[tuple]

Execute and fetch a single row as a tuple

Detailed examples can be found at Relational API page.

filter(self: duckdb.duckdb.DuckDBPyRelation, filter_expr: object) duckdb.duckdb.DuckDBPyRelation

Filter the relation object by the filter in filter_expr

Detailed examples can be found at Relational API page.

first(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Returns the first value of a given column

Detailed examples can be found at Relational API page.

first_value(self: duckdb.duckdb.DuckDBPyRelation, column: str, window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the first value within the group or partition

Detailed examples can be found at Relational API page.

fsum(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the sum of all values present in a given column using a more accurate floating point summation (Kahan Sum)

Detailed examples can be found at Relational API page.

geomean(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the geometric mean over all values present in a given column

Detailed examples can be found at Relational API page.

histogram(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the histogram over all values present in a given column

Detailed examples can be found at Relational API page.

insert(self: duckdb.duckdb.DuckDBPyRelation, values: object) None

Inserts the given values into the relation

Detailed examples can be found at Relational API page.

insert_into(self: duckdb.duckdb.DuckDBPyRelation, table_name: str) None

Inserts the relation object into an existing table named table_name

Detailed examples can be found at Relational API page.

intersect(self: duckdb.duckdb.DuckDBPyRelation, other_rel: duckdb.duckdb.DuckDBPyRelation) duckdb.duckdb.DuckDBPyRelation

Create the set intersection of this relation object with another relation object in other_rel

Detailed examples can be found at Relational API page.

join(self: duckdb.duckdb.DuckDBPyRelation, other_rel: duckdb.duckdb.DuckDBPyRelation, condition: object, how: str = 'inner') duckdb.duckdb.DuckDBPyRelation

Join the relation object with another relation object in other_rel using the join condition expression in join_condition. Types supported are ‘inner’, ‘left’, ‘right’, ‘outer’, ‘semi’ and ‘anti’

Detailed examples can be found at Relational API page.

lag(self: duckdb.duckdb.DuckDBPyRelation, column: str, window_spec: str, offset: int = 1, default_value: str = 'NULL', ignore_nulls: bool = False, projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the lag within the partition

Detailed examples can be found at Relational API page.

last(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Returns the last value of a given column

Detailed examples can be found at Relational API page.

last_value(self: duckdb.duckdb.DuckDBPyRelation, column: str, window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the last value within the group or partition

Detailed examples can be found at Relational API page.

lead(self: duckdb.duckdb.DuckDBPyRelation, column: str, window_spec: str, offset: int = 1, default_value: str = 'NULL', ignore_nulls: bool = False, projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the lead within the partition

Detailed examples can be found at Relational API page.

limit(self: duckdb.duckdb.DuckDBPyRelation, n: int, offset: int = 0) duckdb.duckdb.DuckDBPyRelation

Only retrieve the first n rows from this relation object, starting at offset

Detailed examples can be found at Relational API page.

list(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Returns a list containing all values present in a given column

Detailed examples can be found at Relational API page.

map(self: duckdb.duckdb.DuckDBPyRelation, map_function: Callable, *, schema: Optional[object] = None) duckdb.duckdb.DuckDBPyRelation

Calls the passed function on the relation

Detailed examples can be found at Relational API page.

max(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Returns the maximum value present in a given column

Detailed examples can be found at Relational API page.

mean(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the average on a given column

Detailed examples can be found at Relational API page.

median(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the median over all values present in a given column

Detailed examples can be found at Relational API page.

min(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Returns the minimum value present in a given column

Detailed examples can be found at Relational API page.

mode(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the mode over all values present in a given column

Detailed examples can be found at Relational API page.

n_tile(self: duckdb.duckdb.DuckDBPyRelation, window_spec: str, num_buckets: int, projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Divides the partition as equally as possible into num_buckets

Detailed examples can be found at Relational API page.

nth_value(self: duckdb.duckdb.DuckDBPyRelation, column: str, window_spec: str, offset: int, ignore_nulls: bool = False, projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the nth value within the partition

Detailed examples can be found at Relational API page.

order(self: duckdb.duckdb.DuckDBPyRelation, order_expr: str) duckdb.duckdb.DuckDBPyRelation

Reorder the relation object by order_expr

Detailed examples can be found at Relational API page.

percent_rank(self: duckdb.duckdb.DuckDBPyRelation, window_spec: str, projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the relative rank within the partition

Detailed examples can be found at Relational API page.

pl(self: duckdb.duckdb.DuckDBPyRelation, batch_size: int = 1000000) duckdb::PolarsDataFrame

Execute and fetch all rows as a Polars DataFrame

Detailed examples can be found at Relational API page.

product(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Returns the product of all values present in a given column

Detailed examples can be found at Relational API page.

project(self: duckdb.duckdb.DuckDBPyRelation, *args, groups: str = '') duckdb.duckdb.DuckDBPyRelation

Project the relation object by the projection in project_expr

Detailed examples can be found at Relational API page.

quantile(self: duckdb.duckdb.DuckDBPyRelation, column: str, q: object = 0.5, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the exact quantile value for a given column

Detailed examples can be found at Relational API page.

quantile_cont(self: duckdb.duckdb.DuckDBPyRelation, column: str, q: object = 0.5, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the interpolated quantile value for a given column

Detailed examples can be found at Relational API page.

quantile_disc(self: duckdb.duckdb.DuckDBPyRelation, column: str, q: object = 0.5, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the exact quantile value for a given column

Detailed examples can be found at Relational API page.

query(self: duckdb.duckdb.DuckDBPyRelation, virtual_table_name: str, sql_query: str) duckdb.duckdb.DuckDBPyRelation

Run the given SQL query in sql_query on the view named virtual_table_name that refers to the relation object

Detailed examples can be found at Relational API page.

rank(self: duckdb.duckdb.DuckDBPyRelation, window_spec: str, projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the rank within the partition

Detailed examples can be found at Relational API page.

rank_dense(self: duckdb.duckdb.DuckDBPyRelation, window_spec: str, projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the dense rank within the partition

Detailed examples can be found at Relational API page.

record_batch(self: duckdb.duckdb.DuckDBPyRelation, batch_size: int = 1000000) pyarrow.lib.RecordBatchReader

Execute and return an Arrow Record Batch Reader that yields all rows

Detailed examples can be found at Relational API page.

row_number(self: duckdb.duckdb.DuckDBPyRelation, window_spec: str, projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the row number within the partition

Detailed examples can be found at Relational API page.

select(self: duckdb.duckdb.DuckDBPyRelation, *args, groups: str = '') duckdb.duckdb.DuckDBPyRelation

Project the relation object by the projection in project_expr

Detailed examples can be found at Relational API page.

select_dtypes(self: duckdb.duckdb.DuckDBPyRelation, types: object) duckdb.duckdb.DuckDBPyRelation

Select columns from the relation, by filtering based on type(s)

Detailed examples can be found at Relational API page.

select_types(self: duckdb.duckdb.DuckDBPyRelation, types: object) duckdb.duckdb.DuckDBPyRelation

Select columns from the relation, by filtering based on type(s)

Detailed examples can be found at Relational API page.

set_alias(self: duckdb.duckdb.DuckDBPyRelation, alias: str) duckdb.duckdb.DuckDBPyRelation

Rename the relation object to new alias

Detailed examples can be found at Relational API page.

shape

Tuple of # of rows, # of columns in relation.

Detailed examples can be found at Relational API page.

show(self: duckdb.duckdb.DuckDBPyRelation, *, max_width: Optional[int] = None, max_rows: Optional[int] = None, max_col_width: Optional[int] = None, null_value: Optional[str] = None, render_mode: object = None) None

Display a summary of the data

Detailed examples can be found at Relational API page.

sort(self: duckdb.duckdb.DuckDBPyRelation, *args) duckdb.duckdb.DuckDBPyRelation

Reorder the relation object by the provided expressions

Detailed examples can be found at Relational API page.

sql_query(self: duckdb.duckdb.DuckDBPyRelation) str

Get the SQL query that is equivalent to the relation

Detailed examples can be found at Relational API page.

std(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the sample standard deviation for a given column

Detailed examples can be found at Relational API page.

stddev(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the sample standard deviation for a given column

Detailed examples can be found at Relational API page.

stddev_pop(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the population standard deviation for a given column

Detailed examples can be found at Relational API page.

stddev_samp(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the sample standard deviation for a given column

Detailed examples can be found at Relational API page.

string_agg(self: duckdb.duckdb.DuckDBPyRelation, column: str, sep: str = ',', groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Concatenates the values present in a given column with a separator

Detailed examples can be found at Relational API page.

sum(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the sum of all values present in a given column

Detailed examples can be found at Relational API page.

tf(self: duckdb.duckdb.DuckDBPyRelation) dict

Fetch a result as dict of TensorFlow Tensors

Detailed examples can be found at Relational API page.

to_arrow_table(self: duckdb.duckdb.DuckDBPyRelation, batch_size: int = 1000000) pyarrow.lib.Table

Execute and fetch all rows as an Arrow Table

Detailed examples can be found at Relational API page.

to_csv(self: duckdb.duckdb.DuckDBPyRelation, file_name: str, *, sep: object = None, na_rep: object = None, header: object = None, quotechar: object = None, escapechar: object = None, date_format: object = None, timestamp_format: object = None, quoting: object = None, encoding: object = None, compression: object = None, overwrite: object = None, per_thread_output: object = None, use_tmp_file: object = None, partition_by: object = None, write_partition_columns: object = None) None

Write the relation object to a CSV file in ‘file_name’

Detailed examples can be found at Relational API page.

to_df(self: duckdb.duckdb.DuckDBPyRelation, *, date_as_object: bool = False) pandas.DataFrame

Execute and fetch all rows as a pandas DataFrame

Detailed examples can be found at Relational API page.

to_parquet(self: duckdb.duckdb.DuckDBPyRelation, file_name: str, *, compression: object = None, field_ids: object = None, row_group_size_bytes: object = None, row_group_size: object = None, overwrite: object = None, per_thread_output: object = None, use_tmp_file: object = None, partition_by: object = None, write_partition_columns: object = None, append: object = None) None

Write the relation object to a Parquet file in ‘file_name’

Detailed examples can be found at Relational API page.

to_table(self: duckdb.duckdb.DuckDBPyRelation, table_name: str) None

Creates a new table named table_name with the contents of the relation object

Detailed examples can be found at Relational API page.

to_view(self: duckdb.duckdb.DuckDBPyRelation, view_name: str, replace: bool = True) duckdb.duckdb.DuckDBPyRelation

Creates a view named view_name that refers to the relation object

Detailed examples can be found at Relational API page.

torch(self: duckdb.duckdb.DuckDBPyRelation) dict

Fetch a result as dict of PyTorch Tensors

Detailed examples can be found at Relational API page.

type

Get the type of the relation.

Detailed examples can be found at Relational API page.

types

Return a list containing the types of the columns of the relation.

Detailed examples can be found at Relational API page.

union(self: duckdb.duckdb.DuckDBPyRelation, union_rel: duckdb.duckdb.DuckDBPyRelation) duckdb.duckdb.DuckDBPyRelation

Create the set union of this relation object with another relation object in other_rel

Detailed examples can be found at Relational API page.

unique(self: duckdb.duckdb.DuckDBPyRelation, unique_aggr: str) duckdb.duckdb.DuckDBPyRelation

Returns the distinct values in a column.

Detailed examples can be found at Relational API page.

update(self: duckdb.duckdb.DuckDBPyRelation, set: object, *, condition: object = None) None

Update the given relation with the provided expressions

Detailed examples can be found at Relational API page.

value_counts(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the number of elements present in a given column, also projecting the original column

Detailed examples can be found at Relational API page.

var(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the sample variance for a given column

Detailed examples can be found at Relational API page.

var_pop(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the population variance for a given column

Detailed examples can be found at Relational API page.

var_samp(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the sample variance for a given column

Detailed examples can be found at Relational API page.

variance(self: duckdb.duckdb.DuckDBPyRelation, column: str, groups: str = '', window_spec: str = '', projected_columns: str = '') duckdb.duckdb.DuckDBPyRelation

Computes the sample variance for a given column

Detailed examples can be found at Relational API page.

write_csv(self: duckdb.duckdb.DuckDBPyRelation, file_name: str, *, sep: object = None, na_rep: object = None, header: object = None, quotechar: object = None, escapechar: object = None, date_format: object = None, timestamp_format: object = None, quoting: object = None, encoding: object = None, compression: object = None, overwrite: object = None, per_thread_output: object = None, use_tmp_file: object = None, partition_by: object = None, write_partition_columns: object = None) None

Write the relation object to a CSV file in ‘file_name’

Detailed examples can be found at Relational API page.

write_parquet(self: duckdb.duckdb.DuckDBPyRelation, file_name: str, *, compression: object = None, field_ids: object = None, row_group_size_bytes: object = None, row_group_size: object = None, overwrite: object = None, per_thread_output: object = None, use_tmp_file: object = None, partition_by: object = None, write_partition_columns: object = None, append: object = None) None

Write the relation object to a Parquet file in ‘file_name’

Detailed examples can be found at Relational API page.

class duckdb.Error

Bases: Exception

class duckdb.ExpectedResultType

Bases: pybind11_object

Members:

QUERY_RESULT

CHANGED_ROWS

NOTHING

property name
class duckdb.ExplainType

Bases: pybind11_object

Members:

STANDARD

ANALYZE

property name
class duckdb.Expression

Bases: pybind11_object

alias(self: duckdb.duckdb.Expression, arg0: str) duckdb.duckdb.Expression

Create a copy of this expression with the given alias.

Parameters:

name: The alias to use for the expression, this will affect how it can be referenced.

Returns:

Expression: self with an alias.

asc(self: duckdb.duckdb.Expression) duckdb.duckdb.Expression

Set the order by modifier to ASCENDING.

between(self: duckdb.duckdb.Expression, lower: duckdb.duckdb.Expression, upper: duckdb.duckdb.Expression) duckdb.duckdb.Expression
cast(self: duckdb.duckdb.Expression, type: duckdb.duckdb.typing.DuckDBPyType) duckdb.duckdb.Expression

Create a CastExpression to type from self

Parameters:

type: The type to cast to

Returns:

CastExpression: self::type

collate(self: duckdb.duckdb.Expression, collation: str) duckdb.duckdb.Expression
desc(self: duckdb.duckdb.Expression) duckdb.duckdb.Expression

Set the order by modifier to DESCENDING.

get_name(self: duckdb.duckdb.Expression) str

Return the stringified version of the expression.

Returns:

str: The string representation.

isin(self: duckdb.duckdb.Expression, *args) duckdb.duckdb.Expression

Return an IN expression comparing self to the input arguments.

Returns:

DuckDBPyExpression: The compare IN expression

isnotin(self: duckdb.duckdb.Expression, *args) duckdb.duckdb.Expression

Return a NOT IN expression comparing self to the input arguments.

Returns:

DuckDBPyExpression: The compare NOT IN expression

isnotnull(self: duckdb.duckdb.Expression) duckdb.duckdb.Expression

Create a binary IS NOT NULL expression from self

Returns:

DuckDBPyExpression: self IS NOT NULL

isnull(self: duckdb.duckdb.Expression) duckdb.duckdb.Expression

Create a binary IS NULL expression from self

Returns:

DuckDBPyExpression: self IS NULL

nulls_first(self: duckdb.duckdb.Expression) duckdb.duckdb.Expression

Set the NULL order by modifier to NULLS FIRST.

nulls_last(self: duckdb.duckdb.Expression) duckdb.duckdb.Expression

Set the NULL order by modifier to NULLS LAST.

otherwise(self: duckdb.duckdb.Expression, value: duckdb.duckdb.Expression) duckdb.duckdb.Expression

Add an ELSE <value> clause to the CaseExpression.

Parameters:

value: The value to use if none of the WHEN conditions are met.

Returns:

CaseExpression: self with an ELSE clause.

show(self: duckdb.duckdb.Expression) None

Print the stringified version of the expression.

when(self: duckdb.duckdb.Expression, condition: duckdb.duckdb.Expression, value: duckdb.duckdb.Expression) duckdb.duckdb.Expression

Add an additional WHEN <condition> THEN <value> clause to the CaseExpression.

Parameters:

condition: The condition that must be met. value: The value to use if the condition is met.

Returns:

CaseExpression: self with an additional WHEN clause.

class duckdb.FatalException

Bases: DatabaseError

class duckdb.FloatValue(object: Any)

Bases: Value

duckdb.FunctionExpression(function_name: str, *args) duckdb.duckdb.Expression
class duckdb.HTTPException

Bases: IOException

Thrown when an error occurs in the httpfs extension, or whilst downloading an extension.

class duckdb.HugeIntegerValue(object: Any)

Bases: Value

class duckdb.IOException

Bases: OperationalError

class duckdb.IntegerValue(object: Any)

Bases: Value

class duckdb.IntegrityError

Bases: DatabaseError

class duckdb.InternalError

Bases: DatabaseError

class duckdb.InternalException

Bases: InternalError

class duckdb.InterruptException

Bases: DatabaseError

class duckdb.IntervalValue(object: Any)

Bases: Value

class duckdb.InvalidInputException

Bases: ProgrammingError

class duckdb.InvalidTypeException

Bases: ProgrammingError

duckdb.LambdaExpression(lhs: object, rhs: duckdb.duckdb.Expression) duckdb.duckdb.Expression
class duckdb.LongValue(object: Any)

Bases: Value

class duckdb.NotImplementedException

Bases: NotSupportedError

class duckdb.NotSupportedError

Bases: DatabaseError

class duckdb.NullValue

Bases: Value

class duckdb.OperationalError

Bases: DatabaseError

class duckdb.OutOfMemoryException

Bases: OperationalError

class duckdb.OutOfRangeException

Bases: DataError

class duckdb.ParserException

Bases: ProgrammingError

class duckdb.PermissionException

Bases: DatabaseError

class duckdb.ProgrammingError

Bases: DatabaseError

class duckdb.PythonExceptionHandling

Bases: pybind11_object

Members:

DEFAULT

RETURN_NULL

property name
class duckdb.RenderMode

Bases: pybind11_object

Members:

ROWS

COLUMNS

property name
duckdb.SQLExpression(expression: str) duckdb.duckdb.Expression
class duckdb.SequenceException

Bases: DatabaseError

class duckdb.SerializationException

Bases: OperationalError

class duckdb.ShortValue(object: Any)

Bases: Value

duckdb.StarExpression(*args, **kwargs)

Overloaded function.

  1. StarExpression(*, exclude: object = None) -> duckdb.duckdb.Expression

  2. StarExpression() -> duckdb.duckdb.Expression

class duckdb.Statement

Bases: pybind11_object

property expected_result_type

Get the expected type of result produced by this statement, actual type may vary depending on the statement.

property named_parameters

Get the map of named parameters this statement has.

property query

Get the query equivalent to this statement.

property type

Get the type of the statement.

class duckdb.StatementType

Bases: pybind11_object

Members:

INVALID

SELECT

INSERT

UPDATE

CREATE

DELETE

PREPARE

EXECUTE

ALTER

TRANSACTION

COPY

ANALYZE

VARIABLE_SET

CREATE_FUNC

EXPLAIN

DROP

EXPORT

PRAGMA

VACUUM

CALL

SET

LOAD

RELATION

EXTENSION

LOGICAL_PLAN

ATTACH

DETACH

MULTI

COPY_DATABASE

property name
class duckdb.StringValue(object: Any)

Bases: Value

class duckdb.SyntaxException

Bases: ProgrammingError

class duckdb.TimeTimeZoneValue(object: Any)

Bases: Value

class duckdb.TimeValue(object: Any)

Bases: Value

class duckdb.TimestampMilisecondValue(object: Any)

Bases: Value

class duckdb.TimestampNanosecondValue(object: Any)

Bases: Value

class duckdb.TimestampSecondValue(object: Any)

Bases: Value

class duckdb.TimestampTimeZoneValue(object: Any)

Bases: Value

class duckdb.TimestampValue(object: Any)

Bases: Value

class duckdb.TransactionException

Bases: OperationalError

class duckdb.TypeMismatchException

Bases: DataError

class duckdb.UUIDValue(object: Any)

Bases: Value

class duckdb.UnsignedBinaryValue(object: Any)

Bases: Value

class duckdb.UnsignedIntegerValue(object: Any)

Bases: Value

class duckdb.UnsignedLongValue(object: Any)

Bases: Value

class duckdb.UnsignedShortValue(object: Any)

Bases: Value

class duckdb.Value(object: Any, type: DuckDBPyType)

Bases: object

class duckdb.Warning

Bases: Exception

duckdb.aggregate(df: pandas.DataFrame, aggr_expr: object, group_expr: str = '', *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.DuckDBPyRelation

Compute the aggregate aggr_expr by the optional groups group_expr on the relation

duckdb.alias(df: pandas.DataFrame, alias: str, *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.DuckDBPyRelation

Rename the relation object to new alias

duckdb.append(table_name: str, df: pandas.DataFrame, *, by_name: bool = False, connection: duckdb.DuckDBPyConnection = None) duckdb.DuckDBPyConnection

Append the passed DataFrame to the named table

duckdb.array_type(type: duckdb.duckdb.typing.DuckDBPyType, size: int, *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.typing.DuckDBPyType

Create an array type object of ‘type’

duckdb.arrow(*args, **kwargs)

Overloaded function.

  1. arrow(rows_per_batch: int = 1000000, *, connection: duckdb.DuckDBPyConnection = None) -> pyarrow.lib.Table

Fetch a result as Arrow table following execute()

  1. arrow(rows_per_batch: int = 1000000, *, connection: duckdb.DuckDBPyConnection = None) -> pyarrow.lib.Table

Fetch a result as Arrow table following execute()

  1. arrow(arrow_object: object, *, connection: duckdb.DuckDBPyConnection = None) -> duckdb.duckdb.DuckDBPyRelation

Create a relation object from an Arrow object

duckdb.begin(*, connection: duckdb.DuckDBPyConnection = None) duckdb.DuckDBPyConnection

Start a new transaction

duckdb.checkpoint(*, connection: duckdb.DuckDBPyConnection = None) duckdb.DuckDBPyConnection

Synchronizes data in the write-ahead log (WAL) to the database data file (no-op for in-memory connections)

duckdb.close(*, connection: duckdb.DuckDBPyConnection = None) None

Close the connection

duckdb.commit(*, connection: duckdb.DuckDBPyConnection = None) duckdb.DuckDBPyConnection

Commit changes performed within a transaction

duckdb.connect(database: object = ':memory:', read_only: bool = False, config: dict = None) duckdb.DuckDBPyConnection

Create a DuckDB database instance. Can take a database file name to read/write persistent data and a read_only flag if no changes are desired

duckdb.create_function(name: str, function: Callable, parameters: object = None, return_type: duckdb.duckdb.typing.DuckDBPyType = None, *, type: duckdb.duckdb.functional.PythonUDFType = <PythonUDFType.NATIVE: 0>, null_handling: duckdb.duckdb.functional.FunctionNullHandling = <FunctionNullHandling.DEFAULT: 0>, exception_handling: duckdb.duckdb.PythonExceptionHandling = <PythonExceptionHandling.DEFAULT: 0>, side_effects: bool = False, connection: duckdb.DuckDBPyConnection = None) duckdb.DuckDBPyConnection

Create a DuckDB function out of the passing in Python function so it can be used in queries

duckdb.cursor(*, connection: duckdb.DuckDBPyConnection = None) duckdb.DuckDBPyConnection

Create a duplicate of the current connection

duckdb.decimal_type(width: int, scale: int, *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.typing.DuckDBPyType

Create a decimal type with ‘width’ and ‘scale’

duckdb.default_connection() duckdb.DuckDBPyConnection

Retrieve the connection currently registered as the default to be used by the module

duckdb.description(*, connection: duckdb.DuckDBPyConnection = None) Optional[list]

Get result set attributes, mainly column names

duckdb.df(*args, **kwargs)

Overloaded function.

  1. df(*, date_as_object: bool = False, connection: duckdb.DuckDBPyConnection = None) -> pandas.DataFrame

Fetch a result as DataFrame following execute()

  1. df(*, date_as_object: bool = False, connection: duckdb.DuckDBPyConnection = None) -> pandas.DataFrame

Fetch a result as DataFrame following execute()

  1. df(df: pandas.DataFrame, *, connection: duckdb.DuckDBPyConnection = None) -> duckdb.duckdb.DuckDBPyRelation

Create a relation object from the DataFrame df

duckdb.distinct(df: pandas.DataFrame, *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.DuckDBPyRelation

Retrieve distinct rows from this relation object

duckdb.dtype(type_str: str, *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.typing.DuckDBPyType

Create a type object by parsing the ‘type_str’ string

duckdb.duplicate(*, connection: duckdb.DuckDBPyConnection = None) duckdb.DuckDBPyConnection

Create a duplicate of the current connection

duckdb.enum_type(name: str, type: duckdb.duckdb.typing.DuckDBPyType, values: list, *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.typing.DuckDBPyType

Create an enum type of underlying ‘type’, consisting of the list of ‘values’

duckdb.execute(query: object, parameters: object = None, *, connection: duckdb.DuckDBPyConnection = None) duckdb.DuckDBPyConnection

Execute the given SQL query, optionally using prepared statements with parameters set

duckdb.executemany(query: object, parameters: object = None, *, connection: duckdb.DuckDBPyConnection = None) duckdb.DuckDBPyConnection

Execute the given prepared statement multiple times using the list of parameter sets in parameters

duckdb.extract_statements(query: str, *, connection: duckdb.DuckDBPyConnection = None) list

Parse the query string and extract the Statement object(s) produced

duckdb.fetch_arrow_table(rows_per_batch: int = 1000000, *, connection: duckdb.DuckDBPyConnection = None) pyarrow.lib.Table

Fetch a result as Arrow table following execute()

duckdb.fetch_df(*, date_as_object: bool = False, connection: duckdb.DuckDBPyConnection = None) pandas.DataFrame

Fetch a result as DataFrame following execute()

duckdb.fetch_df_chunk(vectors_per_chunk: int = 1, *, date_as_object: bool = False, connection: duckdb.DuckDBPyConnection = None) pandas.DataFrame

Fetch a chunk of the result as DataFrame following execute()

duckdb.fetch_record_batch(rows_per_batch: int = 1000000, *, connection: duckdb.DuckDBPyConnection = None) pyarrow.lib.RecordBatchReader

Fetch an Arrow RecordBatchReader following execute()

duckdb.fetchall(*, connection: duckdb.DuckDBPyConnection = None) list

Fetch all rows from a result following execute

duckdb.fetchdf(*, date_as_object: bool = False, connection: duckdb.DuckDBPyConnection = None) pandas.DataFrame

Fetch a result as DataFrame following execute()

duckdb.fetchmany(size: int = 1, *, connection: duckdb.DuckDBPyConnection = None) list

Fetch the next set of rows from a result following execute

duckdb.fetchnumpy(*, connection: duckdb.DuckDBPyConnection = None) dict

Fetch a result as list of NumPy arrays following execute

duckdb.fetchone(*, connection: duckdb.DuckDBPyConnection = None) Optional[tuple]

Fetch a single row from a result following execute

duckdb.filesystem_is_registered(name: str, *, connection: duckdb.DuckDBPyConnection = None) bool

Check if a filesystem with the provided name is currently registered

duckdb.filter(df: pandas.DataFrame, filter_expr: object, *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.DuckDBPyRelation

Filter the relation object by the filter in filter_expr

duckdb.from_arrow(arrow_object: object, *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.DuckDBPyRelation

Create a relation object from an Arrow object

duckdb.from_csv_auto(path_or_buffer: object, **kwargs) duckdb.duckdb.DuckDBPyRelation

Create a relation object from the CSV file in ‘name’

duckdb.from_df(df: pandas.DataFrame, *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.DuckDBPyRelation

Create a relation object from the DataFrame in df

duckdb.from_parquet(*args, **kwargs)

Overloaded function.

  1. from_parquet(file_glob: str, binary_as_string: bool = False, *, file_row_number: bool = False, filename: bool = False, hive_partitioning: bool = False, union_by_name: bool = False, compression: object = None, connection: duckdb.DuckDBPyConnection = None) -> duckdb.duckdb.DuckDBPyRelation

Create a relation object from the Parquet files in file_glob

  1. from_parquet(file_globs: list[str], binary_as_string: bool = False, *, file_row_number: bool = False, filename: bool = False, hive_partitioning: bool = False, union_by_name: bool = False, compression: object = None, connection: duckdb.DuckDBPyConnection = None) -> duckdb.duckdb.DuckDBPyRelation

Create a relation object from the Parquet files in file_globs

duckdb.from_query(query: object, *, alias: str = '', params: object = None, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.DuckDBPyRelation

Run a SQL query. If it is a SELECT statement, create a relation object from the given SQL query, otherwise run the query as-is.

duckdb.get_table_names(query: str, *, connection: duckdb.DuckDBPyConnection = None) set[str]

Extract the required table names from a query

duckdb.install_extension(extension: str, *, force_install: bool = False, repository: object = None, repository_url: object = None, version: object = None, connection: duckdb.DuckDBPyConnection = None) None

Install an extension by name, with an optional version and/or repository to get the extension from

duckdb.interrupt(*, connection: duckdb.DuckDBPyConnection = None) None

Interrupt pending operations

duckdb.limit(df: pandas.DataFrame, n: int, offset: int = 0, *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.DuckDBPyRelation

Only retrieve the first n rows from this relation object, starting at offset

duckdb.list_filesystems(*, connection: duckdb.DuckDBPyConnection = None) list

List registered filesystems, including builtin ones

duckdb.list_type(type: duckdb.duckdb.typing.DuckDBPyType, *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.typing.DuckDBPyType

Create a list type object of ‘type’

duckdb.load_extension(extension: str, *, connection: duckdb.DuckDBPyConnection = None) None

Load an installed extension

duckdb.map_type(key: duckdb.duckdb.typing.DuckDBPyType, value: duckdb.duckdb.typing.DuckDBPyType, *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.typing.DuckDBPyType

Create a map type object from ‘key_type’ and ‘value_type’

duckdb.order(df: pandas.DataFrame, order_expr: str, *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.DuckDBPyRelation

Reorder the relation object by order_expr

duckdb.pl(rows_per_batch: int = 1000000, *, connection: duckdb.DuckDBPyConnection = None) duckdb::PolarsDataFrame

Fetch a result as Polars DataFrame following execute()

duckdb.project(df: pandas.DataFrame, *args, groups: str = '', connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.DuckDBPyRelation

Project the relation object by the projection in project_expr

duckdb.query(query: object, *, alias: str = '', params: object = None, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.DuckDBPyRelation

Run a SQL query. If it is a SELECT statement, create a relation object from the given SQL query, otherwise run the query as-is.

duckdb.query_df(df: pandas.DataFrame, virtual_table_name: str, sql_query: str, *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.DuckDBPyRelation

Run the given SQL query in sql_query on the view named virtual_table_name that refers to the relation object

duckdb.read_csv(path_or_buffer: object, **kwargs) duckdb.duckdb.DuckDBPyRelation

Create a relation object from the CSV file in ‘name’

duckdb.read_json(path_or_buffer: object, *, columns: Optional[object] = None, sample_size: Optional[object] = None, maximum_depth: Optional[object] = None, records: Optional[str] = None, format: Optional[str] = None, date_format: Optional[object] = None, timestamp_format: Optional[object] = None, compression: Optional[object] = None, maximum_object_size: Optional[object] = None, ignore_errors: Optional[object] = None, convert_strings_to_integers: Optional[object] = None, field_appearance_threshold: Optional[object] = None, map_inference_threshold: Optional[object] = None, maximum_sample_files: Optional[object] = None, filename: Optional[object] = None, hive_partitioning: Optional[object] = None, union_by_name: Optional[object] = None, hive_types: Optional[object] = None, hive_types_autocast: Optional[object] = None, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.DuckDBPyRelation

Create a relation object from the JSON file in ‘name’

duckdb.read_parquet(*args, **kwargs)

Overloaded function.

  1. read_parquet(file_glob: str, binary_as_string: bool = False, *, file_row_number: bool = False, filename: bool = False, hive_partitioning: bool = False, union_by_name: bool = False, compression: object = None, connection: duckdb.DuckDBPyConnection = None) -> duckdb.duckdb.DuckDBPyRelation

Create a relation object from the Parquet files in file_glob

  1. read_parquet(file_globs: list[str], binary_as_string: bool = False, *, file_row_number: bool = False, filename: bool = False, hive_partitioning: bool = False, union_by_name: bool = False, compression: object = None, connection: duckdb.DuckDBPyConnection = None) -> duckdb.duckdb.DuckDBPyRelation

Create a relation object from the Parquet files in file_globs

duckdb.register(view_name: str, python_object: object, *, connection: duckdb.DuckDBPyConnection = None) duckdb.DuckDBPyConnection

Register the passed Python Object value for querying with a view

duckdb.register_filesystem(filesystem: fsspec.AbstractFileSystem, *, connection: duckdb.DuckDBPyConnection = None) None

Register a fsspec compliant filesystem

duckdb.remove_function(name: str, *, connection: duckdb.DuckDBPyConnection = None) duckdb.DuckDBPyConnection

Remove a previously created function

duckdb.rollback(*, connection: duckdb.DuckDBPyConnection = None) duckdb.DuckDBPyConnection

Roll back changes performed within a transaction

duckdb.row_type(fields: object, *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.typing.DuckDBPyType

Create a struct type object from ‘fields’

duckdb.rowcount(*, connection: duckdb.DuckDBPyConnection = None) int

Get result set row count

duckdb.set_default_connection(connection: duckdb.DuckDBPyConnection) None

Register the provided connection as the default to be used by the module

duckdb.sql(query: object, *, alias: str = '', params: object = None, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.DuckDBPyRelation

Run a SQL query. If it is a SELECT statement, create a relation object from the given SQL query, otherwise run the query as-is.

duckdb.sqltype(type_str: str, *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.typing.DuckDBPyType

Create a type object by parsing the ‘type_str’ string

duckdb.string_type(collation: str = '', *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.typing.DuckDBPyType

Create a string type with an optional collation

duckdb.struct_type(fields: object, *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.typing.DuckDBPyType

Create a struct type object from ‘fields’

duckdb.table(table_name: str, *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.DuckDBPyRelation

Create a relation object for the named table

duckdb.table_function(name: str, parameters: object = None, *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.DuckDBPyRelation

Create a relation object from the named table function with given parameters

duckdb.tf(*, connection: duckdb.DuckDBPyConnection = None) dict

Fetch a result as dict of TensorFlow Tensors following execute()

class duckdb.token_type

Bases: pybind11_object

Members:

identifier

numeric_const

string_const

operator

keyword

comment

property name
duckdb.tokenize(query: str) list

Tokenizes a SQL string, returning a list of (position, type) tuples that can be used for e.g., syntax highlighting

duckdb.torch(*, connection: duckdb.DuckDBPyConnection = None) dict

Fetch a result as dict of PyTorch Tensors following execute()

duckdb.type(type_str: str, *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.typing.DuckDBPyType

Create a type object by parsing the ‘type_str’ string

duckdb.union_type(members: object, *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.typing.DuckDBPyType

Create a union type object from ‘members’

duckdb.unregister(view_name: str, *, connection: duckdb.DuckDBPyConnection = None) duckdb.DuckDBPyConnection

Unregister the view name

duckdb.unregister_filesystem(name: str, *, connection: duckdb.DuckDBPyConnection = None) None

Unregister a filesystem

duckdb.values(*args, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.DuckDBPyRelation

Create a relation object from the passed values

duckdb.view(view_name: str, *, connection: duckdb.DuckDBPyConnection = None) duckdb.duckdb.DuckDBPyRelation

Create a relation object for the named view

duckdb.write_csv(df: pandas.DataFrame, filename: str, *, sep: object = None, na_rep: object = None, header: object = None, quotechar: object = None, escapechar: object = None, date_format: object = None, timestamp_format: object = None, quoting: object = None, encoding: object = None, compression: object = None, overwrite: object = None, per_thread_output: object = None, use_tmp_file: object = None, partition_by: object = None, write_partition_columns: object = None, connection: duckdb.DuckDBPyConnection = None) None

Write the relation object to a CSV file in ‘file_name’