Database drivers become optional extras
Maintainer antworten meist innerhalb von 6 Tagen
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Refactoring
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- mysql, postgresql, python
- Bereich
- backend, build-system, databases
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Python
- Sterne
- 198
- Forks
- 103
- Ø Merge
- 6 T. 1 Std.
- Gemergte PRs (30 T.)
- 10
Entwicklungsumgebung
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus datajoint/datajoint-python
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
datajoint/datajoint-python#1703 ·
Maintainer antworten meist innerhalb von 6 Tagen
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
datajoint/datajoint-python#1702 ·
Maintainer antworten meist innerhalb von 6 Tagen
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
datajoint/datajoint-python#1701 ·
Maintainer antworten meist innerhalb von 6 Tagen
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
datajoint/datajoint-python#1691 ·
Maintainer antworten meist innerhalb von 6 Tagen
-
dependencies needs-discussion
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
datajoint/datajoint-python#1687 ·
Maintainer antworten meist innerhalb von 6 Tagen
Alle Issues in datajoint/datajoint-python
Ähnliche Issues
-
needs-triage
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 85/100
gke-labs/kube-agents#6620 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
open-webui/open-webui#34719 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
cognition
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
One non-object JSON record makes the session catalog exitEvtl. vergeben @he-yufeng hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 78/100
collabnix/awesome-mcp-lists#433 ·
Maintainer antworten meist innerhalb von 4 Tagen