dkdc-lake
Core DuckDB/DuckLake functionality for dkdc (don't know, don't care).
Overview
This crate provides the core data lake functionality using DuckDB with the DuckLake extension for encrypted storage. It implements:
- DuckDB connection management with DuckLake extension
- File storage and retrieval
- Secret management with encryption
- Archive storage
- Virtual filesystem abstraction
Architecture
The lake uses a two-database architecture:
- metadata.db: SQLite database storing metadata
- data/: DuckLake encrypted data files
All data is stored using a unified file-based schema:
{table_name} (
filepath VARCHAR, -- Virtual path (e.g., "./files", "./secrets")
filename VARCHAR, -- File or secret name
filedata BLOB, -- Actual content
filesize BIGINT, -- Size in bytes
fileupdated TIMESTAMP -- Last update time
)
Usage
use Lake;
// Create a new lake instance
let lake = new?;
// Store a file
lake.add_file?;
// Retrieve a file
if let Some = lake.get_file?
// Store a secret
lake.set_secret?;
// List files in a directory
let files = lake.list_files?;
Features
- Encrypted Storage: All data is encrypted at rest using DuckLake
- Version History: Stores all versions of files/secrets
- Virtual Filesystem: Organize data using virtual paths
- SQL Access: Direct SQL access for advanced queries
SQL Commands
Get the SQL commands to set up the lake manually:
let sql = lake.get_sql_commands;
This returns:
INSTALL ducklake;
INSTALL sqlite;
ATTACH '/path/to/metadata.db' AS metadata;
ATTACH 'ducklake:sqlite:/path/to/metadata.db' AS data (DATA_PATH '/path/to/data', ENCRYPTED);
USE data;
Dependencies
duckdb: DuckDB database with bundled supportdkdc-config: Configuration managementchrono: Timestamp handlinganyhow: Error handling