docs.rs failed to build prax-duckdb-0.12.2
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
prax-duckdb-0.12.0
prax-duckdb
DuckDB database driver for the Prax ORM, optimized for analytical workloads (OLAP).
Features
- In-process analytics: No server required, runs embedded in your application
- Columnar storage: Optimized for analytical queries with fast aggregations
- Parquet support: Native reading/writing of Parquet files
- JSON support: Query JSON data directly
- CSV support: Import and export CSV files
- SQL compatibility: Full SQL support with analytical extensions
- Async support: Async operations via Tokio task spawning
- Connection pooling: Efficient connection management for concurrent access
When to Use DuckDB
DuckDB excels at:
- Analytical queries: Aggregations, joins, window functions
- Data transformation: ETL pipelines and data processing
- File-based querying: Direct queries on Parquet, CSV, and JSON files
- Embedded analytics: Adding analytics to applications without a separate database server
For OLTP workloads (many small transactions), consider PostgreSQL or SQLite instead.
Installation
Add to your Cargo.toml:
[]
= "0.3"
Quick Start
use ;
async
Configuration
In-Memory Database
let config = in_memory;
File-Based Database
let config = from_path?;
From URL
let config = from_url?;
Builder Pattern
let config = builder
.path
.threads
.memory_limit
.read_only
.build;
Analytical Features
Window Functions
let sql = r#"
SELECT
date,
revenue,
SUM(revenue) OVER (
PARTITION BY region
ORDER BY date
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) as cumulative_revenue,
AVG(revenue) OVER (
PARTITION BY region
ORDER BY date
ROWS BETWEEN 6 PRECEDING AND CURRENT ROW
) as rolling_avg
FROM sales
"#;
let results = engine.execute_raw.await?;
Parquet Files
// Query Parquet files directly
let results = engine.query_parquet.await?;
// Export to Parquet
engine.copy_to_parquet.await?;
CSV Files
// Query CSV files
let results = engine.query_csv.await?; // true = has header
// Export to CSV
engine.copy_to_csv.await?;
JSON Files
// Query JSON files
let results = engine.query_json.await?;
Connection Pooling
let pool = builder
.in_memory
.max_connections
.min_connections
.build
.await?;
// Get a connection
let conn = pool.get.await?;
// Connection is automatically returned to pool when dropped
Transactions
let conn = pool.get.await?;
// Manual transaction management
conn.execute_batch.await?;
conn.execute.await?;
conn.execute_batch.await?;
// Or use savepoints
conn.execute_batch.await?;
// ... operations ...
conn.execute_batch.await?;
Error Handling
use ;
Features
| Feature | Description |
|---|---|
bundled |
Bundle DuckDB library (default) |
json |
JSON extension support |
parquet |
Parquet file support |
chrono |
Chrono date/time support |
serde_json |
Serde JSON support |
uuid |
UUID support |
extensions-full |
All extensions (json, parquet, etc.) |
Performance Tips
- Use Parquet for large datasets: Columnar format is much faster for analytical queries
- Limit memory for large queries: Set
memory_limitto prevent OOM - Use appropriate thread count: DuckDB can parallelize queries across threads
- Batch operations: Use multi-row inserts and batch statements
- **Avoid SELECT ***: Only select columns you need
License
MIT OR Apache-2.0