File size: 1,565 Bytes
a2a09f6
5dc86cf
 
 
 
a2a09f6
5dc86cf
 
 
a2a09f6
 
5dc86cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
---
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