Skip to main content

A DuckDB appender for Python

Project description

DuckDB PyAppender

A DuckDB appender for Python.

Installation

Usage

import duckdb
from duckdb_appender import Appender

conn = duckdb.connect()

appender = Appender(conn, schema="main", table="users")
appender.append_row([1, "John"])
appender.append_row([2, "Doe"])
appender.close()

# Can also use it with context manager:
with Appender(conn, schema="main", table="users") as appender:
  appender.append_row([3, "foo"])

See more in the /examples folder.

Why use this

  • Much faster than simple INSERT statements.
  • Versus storing data in a pandas DataFrame and load into DuckDB: while pandas loads the entire dataset into memory, this appender uses SQLite as a buffer that regularly flush itself (every 204,800 rows, similar to the official C++ appender)
    • This prevents memory overload on large data aggregation.
    • A little bit of crash protection - since it commits data every 204,800 rows, you'll preserve most of your progress if something goes wrong.

Local development

This repo uses uv to manage dependencies and virtual environment. Dependencies are written in pyproject.toml, so other tools supporting it can be used as well.

Run test

This repo use pytest. To run tests within an uv environment, run:

uv run pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

duckdb_appender-0.3.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

duckdb_appender-0.3.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file duckdb_appender-0.3.1.tar.gz.

File metadata

  • Download URL: duckdb_appender-0.3.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for duckdb_appender-0.3.1.tar.gz
Algorithm Hash digest
SHA256 3d8c19876d3f44124addf91bbf49f33ef0f2cf6d8414c3845e61f8791f8f21a0
MD5 c58acebac4464eb5ed353aed8c35e5be
BLAKE2b-256 6cbb8748226361a22b888e8ca6bc2bc7a846a5980f6c75d05b7f9925f78b4d1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for duckdb_appender-0.3.1.tar.gz:

Publisher: publish.yaml on toanphan19/duckdb-appender

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file duckdb_appender-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for duckdb_appender-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 56a390ff7a242d801efbe1ac8230525ea7f21a587ea2c2ff550467c54421eeeb
MD5 8d630328d663648e9ad486b61847899f
BLAKE2b-256 49ac0cd4a62d31ca3b3b3ad8009f6409dc6f8414a5c8faeeb954f0a25eb854f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for duckdb_appender-0.3.1-py3-none-any.whl:

Publisher: publish.yaml on toanphan19/duckdb-appender

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page