PostgreSQL becomes the default backend

未关闭
#1,627 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 6 天内回复

@dimitri-yatsenko 已经在做这个了。

开始于 2026年10月17日。

  • #1629 来自 @dimitri-yatsenko —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
停滞
技术栈
docker-compose, mysql, postgresql, python

调研方向

Start with the database backend configuration and connection setup, then inspect the settings docstring, CLI help, docker-compose.yaml, and CONTRIBUTING.md; the issue does not name source files. Update PostgreSQL defaults and backend-aware port selection, while ensuring MySQL fixtures and users select MySQL explicitly. Run the relevant test suite and verify dj.config.save_template(), connection error behavior, and documentation examples.

由索引模型根据 Issue 内容生成。

描述

enhancement

Motivation

DataJoint supports PostgreSQL and MySQL as production backends, with the same features on both. Today database.backend defaults to "mysql", so a new user who installs DataJoint and connects without configuring a backend gets MySQL.

PostgreSQL becomes the default backend. A new install should work against PostgreSQL with no backend setting, and the documentation, examples, and test runs should lead with it. MySQL stays a fully supported backend; selecting it takes one setting.

The change

  • database.backend defaults to "postgresql", and the default port is 5432.

  • The port follows the backend unless it is set. Today the port is derived only when the settings are first built, so database.backend set in datajoint.json or assigned at run time leaves the other backend's port in place. After this change, backend: "mysql" with no port connects on 3306.

  • If a connection fails while the backend is still the default, so that neither the configuration nor the code chose one, the error adds:

    The default backend is postgresql since DataJoint 2.4; set database.backend='mysql' (DJ_BACKEND=mysql) for a MySQL server.
    

    A backend set by DJ_BACKEND, datajoint.json, dj.config, or the backend argument of dj.Connection / dj.Instance counts as chosen, and its connection errors are raised unchanged.

  • dj.config.save_template() writes "backend": "postgresql" and port 5432.

  • The settings docstring, CLI help, docker-compose.yaml, and CONTRIBUTING.md list PostgreSQL first.

  • The test fixtures that connect to the MySQL test server select MySQL explicitly instead of relying on the default.

Migration for MySQL users

Select the MySQL backend in any one of these ways:

  • Environment: export DJ_BACKEND=mysql

  • datajoint.json:

    {
      "database": {
        "backend": "mysql",
        "host": "db.example.org"
      }
    }
    
  • In code, before connecting: dj.config["database.backend"] = "mysql"

  • For an isolated instance: dj.Instance(host=..., user=..., password=..., backend="mysql")

With the backend set, the port defaults to 3306. A port set explicitly (DJ_PORT, database.port, or host:port) is kept as is. A MySQL setup that sets no backend fails to connect with the message above.

主要语言
Python
星标
198
派生
103
平均合并
6 天 1 小时
30 天内合并 PR
10

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

datajoint/datajoint-python 的其他 Issue

查看 datajoint/datajoint-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。