duckdb-sqlalchemy 0.19.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- duckdb_sqlalchemy/__init__.py +1411 -0
- duckdb_sqlalchemy/_supports.py +23 -0
- duckdb_sqlalchemy/bulk.py +192 -0
- duckdb_sqlalchemy/capabilities.py +24 -0
- duckdb_sqlalchemy/config.py +70 -0
- duckdb_sqlalchemy/conftest.py +0 -0
- duckdb_sqlalchemy/datatypes.py +332 -0
- duckdb_sqlalchemy/motherduck.py +237 -0
- duckdb_sqlalchemy/olap.py +39 -0
- duckdb_sqlalchemy/py.typed +0 -0
- duckdb_sqlalchemy/requirements.py +5 -0
- duckdb_sqlalchemy/tests/__init__.py +0 -0
- duckdb_sqlalchemy/tests/conftest.py +55 -0
- duckdb_sqlalchemy/tests/snapshots/test_datatypes/test_interval/schema.sql +3 -0
- duckdb_sqlalchemy/tests/sqlalchemy_suite/conftest.py +11 -0
- duckdb_sqlalchemy/tests/sqlalchemy_suite/test_suite.py +1 -0
- duckdb_sqlalchemy/tests/test_basic.py +718 -0
- duckdb_sqlalchemy/tests/test_core_units.py +474 -0
- duckdb_sqlalchemy/tests/test_datatypes.py +251 -0
- duckdb_sqlalchemy/tests/test_execution_options.py +32 -0
- duckdb_sqlalchemy/tests/test_helpers.py +71 -0
- duckdb_sqlalchemy/tests/test_integration.py +46 -0
- duckdb_sqlalchemy/tests/test_pandas.py +146 -0
- duckdb_sqlalchemy/tests/test_pyarrow.py +61 -0
- duckdb_sqlalchemy/tests/util.py +9 -0
- duckdb_sqlalchemy/url.py +59 -0
- duckdb_sqlalchemy-0.19.0.dist-info/METADATA +182 -0
- duckdb_sqlalchemy-0.19.0.dist-info/RECORD +31 -0
- duckdb_sqlalchemy-0.19.0.dist-info/WHEEL +4 -0
- duckdb_sqlalchemy-0.19.0.dist-info/entry_points.txt +2 -0
- duckdb_sqlalchemy-0.19.0.dist-info/licenses/LICENSE.txt +21 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: duckdb-sqlalchemy
|
|
3
|
+
Version: 0.19.0
|
|
4
|
+
Summary: SQLAlchemy driver for duckdb
|
|
5
|
+
Project-URL: Bug Tracker, https://github.com/leonardovida/duckdb-sqlalchemy/issues
|
|
6
|
+
Project-URL: Changelog, https://github.com/leonardovida/duckdb-sqlalchemy/releases
|
|
7
|
+
Project-URL: repository, https://github.com/leonardovida/duckdb-sqlalchemy
|
|
8
|
+
Project-URL: Upstream, https://github.com/Mause/duckdb_engine
|
|
9
|
+
Author-email: Leonardo Vida <leonardo@motherduck.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE.txt
|
|
12
|
+
Requires-Python: <4,>=3.9
|
|
13
|
+
Requires-Dist: duckdb>=0.5.0
|
|
14
|
+
Requires-Dist: packaging>=21
|
|
15
|
+
Requires-Dist: sqlalchemy>=1.3.22
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: fsspec<2026.0.0,>=2025.2.0; extra == 'dev'
|
|
18
|
+
Requires-Dist: github-action-utils<2.0.0,>=1.1.0; extra == 'dev'
|
|
19
|
+
Requires-Dist: hypothesis<7.0.0,>=6.75.2; extra == 'dev'
|
|
20
|
+
Requires-Dist: jupysql<0.12.0,>=0.11.1; extra == 'dev'
|
|
21
|
+
Requires-Dist: numpy<2.0,>=1.24; (python_version < '3.12') and extra == 'dev'
|
|
22
|
+
Requires-Dist: numpy<3.0,>=1.26; (python_version >= '3.12' and python_version < '3.13') and extra == 'dev'
|
|
23
|
+
Requires-Dist: numpy<3.0,>=2.0; (python_version >= '3.13') and extra == 'dev'
|
|
24
|
+
Requires-Dist: pandas<2.0,>=1; (python_version < '3.12') and extra == 'dev'
|
|
25
|
+
Requires-Dist: pandas<3.0,>=2.2; (python_version >= '3.12') and extra == 'dev'
|
|
26
|
+
Requires-Dist: pyarrow>=22.0.0; (python_version >= '3.10') and extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest-cov<6.0.0,>=5.0.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-remotedata<0.5.0,>=0.4.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest-snapshot<1.0.0,>=0.9.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest<9.0.0,>=8.0.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: toml<0.11.0,>=0.10.2; extra == 'dev'
|
|
32
|
+
Requires-Dist: ty; extra == 'dev'
|
|
33
|
+
Provides-Extra: devtools
|
|
34
|
+
Requires-Dist: pdbpp<0.12.0,>=0.11.0; extra == 'devtools'
|
|
35
|
+
Requires-Dist: pre-commit>=4.0.0; (python_version >= '3.9') and extra == 'devtools'
|
|
36
|
+
Description-Content-Type: text/markdown
|
|
37
|
+
|
|
38
|
+
# duckdb-sqlalchemy
|
|
39
|
+
|
|
40
|
+
[](https://pypi.org/project/duckdb-sqlalchemy)
|
|
41
|
+
[](https://pypi.org/project/duckdb-sqlalchemy/)
|
|
42
|
+
[](https://pypi.org/project/duckdb-sqlalchemy/)
|
|
43
|
+
[](https://github.com/leonardovida/duckdb-sqlalchemy/actions/workflows/pythonapp.yaml)
|
|
44
|
+
[](https://codecov.io/gh/leonardovida/duckdb-sqlalchemy)
|
|
45
|
+
[](LICENSE.txt)
|
|
46
|
+
|
|
47
|
+
SQLAlchemy dialect for DuckDB and MotherDuck. Run DuckDB locally or connect to MotherDuck with the standard SQLAlchemy APIs. This maintained fork tracks current DuckDB releases and includes MotherDuck-specific helpers and reliability improvements compared to legacy forks.
|
|
48
|
+
|
|
49
|
+
## Highlights
|
|
50
|
+
|
|
51
|
+
- First-class SQLAlchemy dialect (Core + ORM) for DuckDB and MotherDuck.
|
|
52
|
+
- Clean connection URL helpers for MotherDuck routing, attach modes, and read scaling.
|
|
53
|
+
- Practical defaults for pooling, pre-ping, and long-lived app workloads.
|
|
54
|
+
- Optional transient retry for idempotent reads.
|
|
55
|
+
- Actively maintained with a long-term support mindset.
|
|
56
|
+
|
|
57
|
+
## Compatibility
|
|
58
|
+
|
|
59
|
+
| Component | Supported versions |
|
|
60
|
+
| --- | --- |
|
|
61
|
+
| Python | 3.9+ |
|
|
62
|
+
| SQLAlchemy | 1.3.22+ (2.x recommended) |
|
|
63
|
+
| DuckDB | 0.5.0+ (latest recommended) |
|
|
64
|
+
|
|
65
|
+
## Install
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
pip install duckdb-sqlalchemy
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Conda packages are available via conda-forge: https://github.com/conda-forge/duckdb-sqlalchemy-feedstock.
|
|
72
|
+
|
|
73
|
+
## Quick start (DuckDB)
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from sqlalchemy import Column, Integer, String, create_engine
|
|
77
|
+
from sqlalchemy.orm import declarative_base, Session
|
|
78
|
+
|
|
79
|
+
Base = declarative_base()
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class User(Base):
|
|
83
|
+
__tablename__ = "users"
|
|
84
|
+
|
|
85
|
+
id = Column(Integer, primary_key=True)
|
|
86
|
+
name = Column(String)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
engine = create_engine("duckdb:///:memory:")
|
|
90
|
+
Base.metadata.create_all(engine)
|
|
91
|
+
|
|
92
|
+
with Session(engine) as session:
|
|
93
|
+
session.add(User(name="Ada"))
|
|
94
|
+
session.commit()
|
|
95
|
+
assert session.query(User).one().name == "Ada"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Quick start (MotherDuck)
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
export MOTHERDUCK_TOKEN="..."
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from sqlalchemy import create_engine
|
|
106
|
+
|
|
107
|
+
engine = create_engine("duckdb:///md:my_db")
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
MotherDuck uses the `md:` database prefix. Tokens are picked up from `MOTHERDUCK_TOKEN` (or `motherduck_token`) automatically. If your token has special characters, URL-escape it or pass it via `connect_args`.
|
|
111
|
+
|
|
112
|
+
## Connection URLs
|
|
113
|
+
|
|
114
|
+
DuckDB URLs follow the standard SQLAlchemy shape:
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
duckdb:///<database>?<config>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Examples:
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
duckdb:///:memory:
|
|
124
|
+
duckdb:///analytics.db
|
|
125
|
+
duckdb:////absolute/path/to/analytics.db
|
|
126
|
+
duckdb:///md:my_db?attach_mode=single&access_mode=read_only&session_hint=team-a
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Use the URL helpers to build connection strings safely:
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
from duckdb_sqlalchemy import URL, MotherDuckURL
|
|
133
|
+
|
|
134
|
+
local_url = URL(database=":memory:", read_only=False)
|
|
135
|
+
md_url = MotherDuckURL(database="md:my_db", attach_mode="single")
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Configuration and pooling
|
|
139
|
+
|
|
140
|
+
This dialect ships with sensible defaults (NullPool for file/MotherDuck connections, SingletonThreadPool for `:memory:`) and lets you override pooling explicitly. For production services, use the MotherDuck performance helper or configure `QueuePool`, `pool_pre_ping`, and `pool_recycle`.
|
|
141
|
+
|
|
142
|
+
See `docs/configuration.md` and `docs/motherduck.md` for detailed guidance.
|
|
143
|
+
|
|
144
|
+
## Documentation
|
|
145
|
+
|
|
146
|
+
- `docs/README.md` - Docs index
|
|
147
|
+
- `docs/connection-urls.md` - URL formats and helpers
|
|
148
|
+
- `docs/motherduck.md` - MotherDuck setup and options
|
|
149
|
+
- `docs/configuration.md` - Connection configuration, extensions, filesystems
|
|
150
|
+
- `docs/olap.md` - Parquet/CSV scans and ATTACH workflows
|
|
151
|
+
- `docs/pandas-jupyter.md` - DataFrame registration and notebook usage
|
|
152
|
+
- `docs/types-and-caveats.md` - Type support and known caveats
|
|
153
|
+
- `docs/alembic.md` - Alembic integration
|
|
154
|
+
|
|
155
|
+
## Examples
|
|
156
|
+
|
|
157
|
+
- `examples/sqlalchemy_example.py` - end-to-end example
|
|
158
|
+
- `examples/motherduck_read_scaling_per_user.py` - per-user read scaling pattern
|
|
159
|
+
- `examples/motherduck_queuepool_high_concurrency.py` - QueuePool tuning
|
|
160
|
+
- `examples/motherduck_multi_instance_pool.py` - multi-instance pool rotation
|
|
161
|
+
- `examples/motherduck_arrow_reads.py` - Arrow results + streaming
|
|
162
|
+
- `examples/motherduck_attach_modes.py` - workspace vs single attach mode
|
|
163
|
+
|
|
164
|
+
## Release and support policy
|
|
165
|
+
|
|
166
|
+
- Long-term maintenance: this project is intended to remain supported indefinitely.
|
|
167
|
+
- Compatibility: we track current DuckDB and SQLAlchemy releases while preserving SQLAlchemy semantics.
|
|
168
|
+
- Breaking changes: only in major/minor releases with explicit notes in `CHANGELOG.md`.
|
|
169
|
+
- Security: please open an issue with details; we will prioritize fixes.
|
|
170
|
+
|
|
171
|
+
## Changelog and roadmap
|
|
172
|
+
|
|
173
|
+
- `CHANGELOG.md` - release notes
|
|
174
|
+
- `ROADMAP.md` - upcoming work and priorities
|
|
175
|
+
|
|
176
|
+
## Contributing
|
|
177
|
+
|
|
178
|
+
See `AGENTS.md` for repo-specific workflow, tooling, and PR expectations. We welcome issues, bug reports, and high-quality pull requests.
|
|
179
|
+
|
|
180
|
+
## License
|
|
181
|
+
|
|
182
|
+
MIT. See `LICENSE.txt`.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
duckdb_sqlalchemy/__init__.py,sha256=ciVk4nVL75nVkZG1bi6_Og68MZVXciZ-qHbAlXQyHlU,49824
|
|
2
|
+
duckdb_sqlalchemy/_supports.py,sha256=GCOH9nFB4MitnjYKx5V4BsDSCxIfTyXqm6W-BDkgbfE,598
|
|
3
|
+
duckdb_sqlalchemy/bulk.py,sha256=lc6T258-BYQ8fp8xwNVePIrJorjFhg_1FGiEROHKqb8,5209
|
|
4
|
+
duckdb_sqlalchemy/capabilities.py,sha256=Y9l-FaVPMw9CTpsG-42tiqltXECFXqIeTQdXPfSuxPY,719
|
|
5
|
+
duckdb_sqlalchemy/config.py,sha256=uWtsAUyxz0wMn2FQmqknjxkowyICxnbkFWB9gP7vzy4,2203
|
|
6
|
+
duckdb_sqlalchemy/conftest.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
duckdb_sqlalchemy/datatypes.py,sha256=kVUe1gXZuUe9UpzY30CQfEP4VAz308HilCG16sRGmkU,8296
|
|
8
|
+
duckdb_sqlalchemy/motherduck.py,sha256=m6g-Qsd6mfYbKJTuhRYVT7MU6QItDirx4N3IiK0CVuA,7101
|
|
9
|
+
duckdb_sqlalchemy/olap.py,sha256=POaNa8RemilRu0BMbqFhY88oZtyq8MPxx64yIQ85RRc,1078
|
|
10
|
+
duckdb_sqlalchemy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
duckdb_sqlalchemy/requirements.py,sha256=jDDZyI6Pt2IfqeMX83hb-IhQWFMDjHxoW_9j6Txd5pg,112
|
|
12
|
+
duckdb_sqlalchemy/url.py,sha256=y2rtgiHXXcgVpQt22eEIeP8MAeVKwBNC9tsh1i3j3OE,1539
|
|
13
|
+
duckdb_sqlalchemy/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
+
duckdb_sqlalchemy/tests/conftest.py,sha256=GldGGf9wrY1hZvcl4hmzKmdirQYCltpZWfM3-WyOKqc,1498
|
|
15
|
+
duckdb_sqlalchemy/tests/test_basic.py,sha256=CGTHkQfXIm07fxXnSb6jDXI8s9B0E_lCN6q5loDkgrI,21985
|
|
16
|
+
duckdb_sqlalchemy/tests/test_core_units.py,sha256=gqMf4FKyMqNflQlvhoxAX-_WPUKqaJ72jDlnHhJEuOE,13740
|
|
17
|
+
duckdb_sqlalchemy/tests/test_datatypes.py,sha256=g7WwxP6Kq6rhhWdpFUs1g6NA0jNYuaJMiolsRpG0qI8,7144
|
|
18
|
+
duckdb_sqlalchemy/tests/test_execution_options.py,sha256=ov0YVVQLdKdw1K8grdzkpIQMD863dsyB0SG4rkevGks,964
|
|
19
|
+
duckdb_sqlalchemy/tests/test_helpers.py,sha256=9KGRmNVvTVPvcEN3mHCwXIIKhdFe_GXmyBnfWisYiCs,2216
|
|
20
|
+
duckdb_sqlalchemy/tests/test_integration.py,sha256=a9e8BTe4l1ZU8jT220qh0MLffe8Dzf1jAXLNBuVRhJQ,1460
|
|
21
|
+
duckdb_sqlalchemy/tests/test_pandas.py,sha256=EchdBuVwqc1BuGQizg3Xu3WDiTmdVoSuUYA3PsRCd78,4037
|
|
22
|
+
duckdb_sqlalchemy/tests/test_pyarrow.py,sha256=QtjxKTv7-J2LQ0rlB9xon9c46xoECkz4jM8A2a7dlGM,2304
|
|
23
|
+
duckdb_sqlalchemy/tests/util.py,sha256=YHTtB19mxQO--nq1tCnQELcKL_Qh73T9mvdnH6rVlRI,257
|
|
24
|
+
duckdb_sqlalchemy/tests/snapshots/test_datatypes/test_interval/schema.sql,sha256=ZXscZo4xepli7WSjbhWqTufIciscCDLoRznaA6KGiOI,47
|
|
25
|
+
duckdb_sqlalchemy/tests/sqlalchemy_suite/conftest.py,sha256=BVvwaWDIXobKa-ziFyhmjkIkCd5vz0TbT77AFOPCHHc,263
|
|
26
|
+
duckdb_sqlalchemy/tests/sqlalchemy_suite/test_suite.py,sha256=O2O52uLfENDAU_xl2_iZZgigLP1DB8IYaULqCEOnIA8,58
|
|
27
|
+
duckdb_sqlalchemy-0.19.0.dist-info/METADATA,sha256=HWELJl086hxvK-GwxtbZDbLCEZypsS0JE2Az6c_PnsM,7070
|
|
28
|
+
duckdb_sqlalchemy-0.19.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
29
|
+
duckdb_sqlalchemy-0.19.0.dist-info/entry_points.txt,sha256=MyXbmaqEhyBLIL2NnHrweY6EJ_Rke2HnVZR1wCz08cM,57
|
|
30
|
+
duckdb_sqlalchemy-0.19.0.dist-info/licenses/LICENSE.txt,sha256=nhRQcy_ZV2R-xzl3MPltQuQ53bcURavT0N6mC3VdDE8,1076
|
|
31
|
+
duckdb_sqlalchemy-0.19.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020-present Elliana May
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|