Skip to content

Commit 6fe7497

Browse files
docs: Add inst.FreeTable(), clarify base classes vs instance methods
- dj.Manual, dj.Lookup etc. used with @Schema decorator (schema links connection) - inst.Schema(), inst.FreeTable() need connection directly - FreeTable added to Instance class Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f832486 commit 6fe7497

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/design/thread-safe-mode.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,29 @@ Each instance has:
5050
- `inst.config` - Config (created fresh at instance creation)
5151
- `inst.connection` - Connection (created at instance creation)
5252
- `inst.Schema()` - Schema factory using instance's connection
53+
- `inst.FreeTable()` - FreeTable factory using instance's connection
5354

5455
```python
5556
inst = dj.instance(host="localhost", user="u", password="p")
5657
inst.config # Config instance
5758
inst.connection # Connection instance
5859
inst.Schema("name") # Creates schema using inst.connection
60+
inst.FreeTable("db.tbl") # Access table using inst.connection
61+
```
62+
63+
### Table base classes vs instance methods
64+
65+
**Base classes** (`dj.Manual`, `dj.Lookup`, etc.) - Used with `@schema` decorator:
66+
```python
67+
@schema
68+
class Mouse(dj.Manual): # dj.Manual - schema links to connection
69+
definition = "..."
70+
```
71+
72+
**Instance methods** (`inst.Schema()`, `inst.FreeTable()`) - Need connection directly:
73+
```python
74+
schema = inst.Schema("my_schema") # Uses inst.connection
75+
table = inst.FreeTable("db.table") # Uses inst.connection
5976
```
6077

6178
### Thread-safe mode
@@ -151,6 +168,9 @@ class Instance:
151168

152169
def Schema(self, name, **kwargs):
153170
return Schema(name, connection=self.connection, **kwargs)
171+
172+
def FreeTable(self, full_table_name):
173+
return FreeTable(self.connection, full_table_name)
154174
```
155175

156176
### 2. Add dj.instance()

0 commit comments

Comments
 (0)