Database drivers become optional extras
I maintainer di solito rispondono entro 6 giorni
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Refactoring
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- mysql, postgresql, python
- Ambito
- backend, build-system, databases
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 198
- Fork
- 103
- Merge medio
- 6g 1h
- PR unite (30g)
- 10
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di datajoint/datajoint-python
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
datajoint/datajoint-python#1703 ·
I maintainer di solito rispondono entro 6 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
datajoint/datajoint-python#1702 ·
I maintainer di solito rispondono entro 6 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
datajoint/datajoint-python#1701 ·
I maintainer di solito rispondono entro 6 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
datajoint/datajoint-python#1691 ·
I maintainer di solito rispondono entro 6 giorni
-
dependencies needs-discussion
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
datajoint/datajoint-python#1687 ·
I maintainer di solito rispondono entro 6 giorni
Tutte le issue di datajoint/datajoint-python
Issue simili
-
needs-triage
Difficoltà 1/5 1-3 ore Idoneità per principianti 85/100
gke-labs/kube-agents#6620 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
open-webui/open-webui#34719 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
cognition
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
One non-object JSON record makes the session catalog exitForse già presa @he-yufeng l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
collabnix/awesome-mcp-lists#433 ·
I maintainer di solito rispondono entro 4 giorni