Database drivers become optional extras
維護者通常 6 天內回覆
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 35/100
- Issue 類型
- 重構
- 描述清晰度
- 描述清楚
- 活躍度
- 停滯
- 技術堆疊
- mysql, postgresql, python
- 領域
- backend, build-system, databases
研究方向
Start by reviewing the packaging metadata for the PostgreSQL and MySQL extras, the test dependency group, and the adapter registry and connection paths. Update adapters so drivers are imported only when connecting, with missing-driver errors naming the correct extra, while preserving conda run requirements. Run the relevant packaging and adapter tests; done means bare installs load no drivers, each extra supplies its driver, test/dev environments include both, and PostgreSQL code catches DataJointError.
由索引模型根據 Issue 內容生成。
描述
Motivation
DataJoint supports two production database backends, PostgreSQL and MySQL, but the two drivers are packaged differently:
pymysql(MySQL) is a core dependency. Everypip install datajointinstalls it, including installs that only ever connect to PostgreSQL.psycopg2-binary(PostgreSQL) is the optionaldatajoint[postgres]extra.
import datajoint also imports pymysql at load time, through the adapter registry, and imports psycopg2 too when it happens to be installed. A process that never connects to a database still loads both drivers.
Treating the backends alike means each driver is installed only when it is needed. It also leaves room for more backends later without adding a hard dependency for each one.
The change
-
Every database driver becomes an optional extra:
pip install "datajoint[postgres]"installspsycopg2-binarypip install "datajoint[mysql]"installspymysql(same>=0.7.2floor as today)
-
A bare
pip install datajointinstalls no database driver, andimport datajointloads none. -
Each adapter imports its driver when a connection is made. When the driver is missing, connecting raises a
DataJointErrorthat names the extra, e.g.:The MySQL backend requires the pymysql driver, which is not installed. Install it with: pip install "datajoint[mysql]"The PostgreSQL adapter raises the same kind of error. It used to raise
ImportError. -
The PostgreSQL adapter imports the
psycopg2module, so either thepsycopg2or thepsycopg2-binarydistribution satisfies it. -
The
testdependency group and thetestanddevextras install every driver. -
conda has no extras, so the conda-forge package keeps listing the drivers as run requirements.
Migration for MySQL users
- Install the MySQL extra:
pip install "datajoint[mysql]". In a requirements file, writedatajoint[mysql]in place ofdatajoint. - An upgrade in place keeps a
pymysqlthat is already installed. A fresh environment built from a requirements file that lists onlydatajointhas no driver, and the first connection says which extra to install. - Code that caught
ImportErrorfromPostgreSQLAdapter()should catchDataJointError.
- 主要語言
- Python
- 星號
- 198
- 分支
- 103
- 平均合併
- 6 天 1 小時
- 30 天內合併 PR
- 10
環境準備
- 提供 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
datajoint/datajoint-python 的其他 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 78/100
datajoint/datajoint-python#1703 ·
維護者通常 6 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 78/100
datajoint/datajoint-python#1702 ·
維護者通常 6 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 78/100
datajoint/datajoint-python#1701 ·
維護者通常 6 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 74/100
datajoint/datajoint-python#1691 ·
維護者通常 6 天內回覆
-
dependencies needs-discussion
難度 2/5 1-3 小時 新手友好度 68/100
datajoint/datajoint-python#1687 ·
維護者通常 6 天內回覆
查看 datajoint/datajoint-python 的全部 Issue
相似的 Issue
-
needs-triage
難度 1/5 1-3 小時 新手友好度 85/100
gke-labs/kube-agents#6620 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 75/100
open-webui/open-webui#34719 · 2 則留言 ·
維護者通常 1 天內回覆
-
cognition
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
One non-object JSON record makes the session catalog exit可能已有人在做 @he-yufeng 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 78/100
collabnix/awesome-mcp-lists#433 ·
維護者通常 4 天內回覆