@@ -66,6 +66,7 @@ Environment variables take precedence over config files.
6666| ` database.user ` | ` DJ_USER ` | — | Database username |
6767| ` database.password ` | ` DJ_PASS ` | — | Database password |
6868| ` database.backend ` | ` DJ_BACKEND ` | ` mysql ` | Database backend: ` mysql ` or ` postgresql ` |
69+ | ` database.name ` | ` DJ_DATABASE_NAME ` | ` None ` | Database name (PostgreSQL only). Defaults to ` "postgres" ` |
6970| ` database.use_tls ` | ` DJ_TLS ` | ` True ` | Use TLS encryption |
7071| ` database.reconnect ` | — | ` True ` | Auto-reconnect on timeout |
7172| ` safemode ` | — | ` True ` | Prompt before destructive operations |
@@ -145,13 +146,45 @@ DataJoint supports both MySQL and PostgreSQL backends. To use PostgreSQL:
145146
146147The port defaults to ` 5432 ` when ` backend ` is set to ` postgresql ` .
147148
149+ ### Database Name
150+
151+ !!! version-added "New in 2.2.1"
152+ The ` database.name ` setting specifies which PostgreSQL database to connect to.
153+
154+ PostgreSQL requires connecting to a specific database. By default, DataJoint connects to the ` postgres ` database. To use a different database:
155+
156+ ``` json
157+ {
158+ "database" : {
159+ "host" : " localhost" ,
160+ "backend" : " postgresql" ,
161+ "name" : " my_database"
162+ }
163+ }
164+ ```
165+
166+ Or via environment variable:
167+
168+ ``` bash
169+ export DJ_DATABASE_NAME=my_database
170+ ```
171+
172+ Or programmatically:
173+
174+ ``` python
175+ dj.config[' database.name' ] = ' my_database'
176+ ```
177+
178+ This setting only applies to PostgreSQL. Setting it with the MySQL backend emits a warning.
179+
148180### Environment Variable
149181
150182``` bash
151183export DJ_BACKEND=postgresql
152184export DJ_HOST=localhost
153185export DJ_USER=postgres
154186export DJ_PASS=password
187+ export DJ_DATABASE_NAME=my_database # optional, defaults to "postgres"
155188```
156189
157190### Programmatic Configuration
@@ -161,6 +194,7 @@ import datajoint as dj
161194
162195dj.config[' database.backend' ] = ' postgresql'
163196dj.config[' database.host' ] = ' localhost'
197+ dj.config[' database.name' ] = ' my_database' # optional
164198```
165199
166200### Docker Compose for Local Development
0 commit comments