@@ -23,9 +23,9 @@ export DJ_THREAD_SAFE=true
2323{"thread_safe" : true }
2424```
2525
26- ### Create Connections
26+ ### Connection.from_config()
2727
28- All settings can be passed to ` Connection.from_config() ` :
28+ Creates a connection with explicit configuration. Works in both ` thread_safe=True ` and ` thread_safe=False ` modes.
2929
3030``` python
3131conn = dj.Connection.from_config(
@@ -34,11 +34,29 @@ conn = dj.Connection.from_config(
3434 password = " password" ,
3535 safemode = False ,
3636 display_limit = 25 ,
37- # ... any other settings
3837)
3938schema = dj.Schema(" my_schema" , connection = conn)
4039```
4140
41+ ** Parameters:**
42+ - ` host ` (required): Database hostname
43+ - ` user ` (required): Database username
44+ - ` password ` (required): Database password
45+ - ` port ` : Database port (default: 3306)
46+ - Any other setting from ` dj.config ` (e.g., ` safemode ` , ` display_limit ` , ` stores ` )
47+
48+ ** Defaults:** Settings not explicitly provided use hardcoded defaults (same as ` dj.config ` defaults). Global ` dj.config ` is never accessed.
49+
50+ ** Connection-scoped settings:** Stored on ` conn.config ` and accessed as ` conn.config.safemode ` , ` conn.config.display_limit ` , etc.
51+
52+ ``` python
53+ conn = dj.Connection.from_config(host = " localhost" , user = " u" , password = " p" )
54+ conn.config.safemode # True (default)
55+ conn.config.display_limit # 12 (default)
56+
57+ conn.config.safemode = False # Modify for this connection only
58+ ```
59+
4260## Behavior
4361
4462| Operation | ` thread_safe=False ` | ` thread_safe=True ` |
@@ -62,7 +80,10 @@ Only `thread_safe` is read-only after initialization. It can only be set via:
62803 . Add guards to ` Config.__getattr__ ` , ` Config.__setattr__ ` , ` Config.__getitem__ ` , ` Config.__setitem__ `
63814 . Add guard to ` dj.conn() `
64825 . Add guard to ` Schema.__init__ ` when ` connection=None `
65- 6 . Add ` Connection.from_config() ` class method
83+ 6 . Add ` Connection.from_config() ` class method that:
84+ - Accepts all connection params and settings as kwargs
85+ - Uses hardcoded defaults (never accesses global config)
86+ - Creates ` conn.config ` object to store connection-scoped settings
66877 . Add ` ThreadSafetyError ` exception
6788
6889## Exceptions
0 commit comments