Metadata-Version: 2.4
Name: duckdbalchemy
Version: 0.1.0
Summary: Maintained fork of duckdb_engine: SQLAlchemy dialect for DuckDB with complete reflection (PK/FK/index/unique)
Author: liubola
License: MIT
Project-URL: Homepage, https://github.com/liubola/duckdbalchemy
Project-URL: Source, https://github.com/liubola/duckdbalchemy
Project-URL: Issues, https://github.com/liubola/duckdbalchemy/issues
Platform: all
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: duckdb>=0.10
Requires-Dist: sqlalchemy>=2.0
Requires-Dist: typing_extensions>=4.6.0
Requires-Dist: packaging>=21.3
Dynamic: license-file

# duckdbalchemy

Active fork of `duckdb_engine` (which is unmaintained). SQLAlchemy dialect for DuckDB.

## 为什么 fork

`duckdb_engine` 的反射层继承自 PostgreSQL 方言，主键反射查 `pg_catalog`，对 DuckDB 一律返回空——导致 SQLAlchemy 的 `automap` 无法生成 ORM 类。上游已停更，故 fork 自维护。

## 主要改进

- **主键反射**：覆盖 `get_pk_constraint` / `get_multi_pk_constraint`，查 DuckDB `information_schema`，`automap_base.prepare()` 现在能正常生成 mapped class。
- 接管 `duckdb://` scheme（通过 entry_points），对使用 `create_engine("duckdb:///...")` 的代码（如 kepler.wind）零改动。
- 后续：补全外键、唯一约束、索引反射；类型映射优化。

## 安装

```bash
pip uninstall duckdb-engine   # 释放 duckdb:// scheme
pip install -e .
```

## 用法

```python
from sqlalchemy import create_engine
e = create_engine("duckdb:///path/to/db.duckdb")  # 自动用本包的 Dialect
```
