Skip to main content

A custom PySpark extension for writing data to DuckDB

Project description

DuckDB Extension for PySpark

This is a custom PySpark extension that allows writing data from PySpark DataFrames into DuckDB.

Features

  • Seamlessly write PySpark DataFrames to DuckDB
  • Supports overwrite and append modes
  • Automatically detects and adds new columns when appending data
  • Simple integration with PySpark's DataFrameWriter API

Installation

You can install the package using pip:

pip install duckdb-spark


## Usage

Here’s how you can use the extension:

```python
from pyspark.sql import SparkSession
from duckdb_extension import DuckDBWriter

# Initialize Spark Session
spark = SparkSession.builder.appName("DuckDBExample").getOrCreate()

# Create Sample DataFrame
df = spark.createDataFrame([(1, "Alice"), (2, "Bob")], ["id", "name"])

# Write to DuckDB using the custom extension
df.write.duckdb_extension("my_db.duckdb", "users", mode="overwrite")

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

duckdb_spark-1.0.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file duckdb_spark-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: duckdb_spark-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for duckdb_spark-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e228eaa806297038a8977758f7e095d74fc42e5410a8d87ab373b45bb43fd019
MD5 7debc62183459f1538d7827e4973db62
BLAKE2b-256 22b5be248cc67160bdce2dbbceddb64d55fa6c7219e51fac30b1ccb5d040cb70

See more details on using hashes here.

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