--- title: DuckDB FastAPI API emoji: 🦆 colorFrom: blue colorTo: green sdk: docker app_port: 7860 # Optional: specify Python version for clarity, though the Dockerfile defines it # python_version: 3.10 --- # DuckDB FastAPI API This Space provides a simple API built with FastAPI to interact with a DuckDB database. **Features:** * Create tables * Read table data (with limit/offset) * Insert rows into tables * Update rows based on a condition * Delete rows based on a condition * Download a table as CSV * Download the entire database file * Health check endpoint **API Documentation:** The API documentation (powered by Swagger UI) is available at the `/docs` endpoint of your Space URL. **Example Usage (using curl):** ```bash # Health Check curl https://[your-space-subdomain].hf.space/health # Create a table curl -X POST "https://[your-space-subdomain].hf.space/tables/my_data" \ -H "Content-Type: application/json" \ -d '{"columns": [{"name": "id", "type": "INTEGER"}, {"name": "value", "type": "VARCHAR"}]}' # Insert rows curl -X POST "https://[your-space-subdomain].hf.space/tables/my_data/rows" \ -H "Content-Type: application/json" \ -d '{"rows": [{"id": 1, "value": "apple"}, {"id": 2, "value": "banana"}]}' # Read table data curl https://[your-space-subdomain].hf.space/tables/my_data # Download table as CSV curl -o my_data.csv https://[your-space-subdomain].hf.space/download/table/my_data # Download database file curl -o downloaded_db.db https://[your-space-subdomain].hf.space/download/database