You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/reference/configuration.md
+41Lines changed: 41 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -241,6 +241,47 @@ export DJ_PASS=secret
241
241
242
242
**Note:** Per-store credentials must be configured in `datajoint.json` or `.secrets/` — environment variable overrides are not supported for nested store configurations.
243
243
244
+
## Programmatic Access
245
+
246
+
### Reading and Writing Settings
247
+
248
+
Access settings using dot notation on `dj.config`:
249
+
250
+
```python
251
+
import datajoint as dj
252
+
253
+
# Read settings
254
+
print(dj.config.database.host)
255
+
print(dj.config.display.diagram_direction)
256
+
257
+
# Write settings
258
+
dj.config.database.host ="mysql.example.com"
259
+
dj.config.display.diagram_direction ="TB"
260
+
```
261
+
262
+
### Temporary Overrides
263
+
264
+
Use `dj.config.override()` to temporarily change settings within a context:
265
+
266
+
```python
267
+
with dj.config.override(safemode=False):
268
+
# safemode is False here
269
+
(Table & key).delete()
270
+
# safemode is restored to original value
271
+
```
272
+
273
+
**Nested settings syntax:** Since Python doesn't allow dots in keyword argument names, use double underscores (`__`) to access nested settings in `override()`:
274
+
275
+
```python
276
+
# These are equivalent:
277
+
dj.config.display.diagram_direction ="TB"# direct assignment
278
+
279
+
with dj.config.override(display__diagram_direction="TB"): # in override()
280
+
...
281
+
```
282
+
283
+
The double underscore maps to the dot-notation path: `display__diagram_direction` → `display.diagram_direction`.
284
+
244
285
## API Reference
245
286
246
287
See [Settings API](../api/datajoint/settings.md) for programmatic access.
0 commit comments