MCPcopy
hub / github.com/msiemens/tinydb / drop_table

Method drop_table

tinydb/database.py:176–202  ·  view source on GitHub ↗

Drop a specific table from the database. **CANNOT BE REVERSED!** :param name: The name of the table to drop.

(self, name: str)

Source from the content-addressed store, hash-verified

174 self._tables.clear()
175
176 def drop_table(self, name: str) -> None:
177 """
178 Drop a specific table from the database. **CANNOT BE REVERSED!**
179
180 :param name: The name of the table to drop.
181 """
182
183 # If the table is currently opened, we need to forget the table class
184 # instance
185 if name in self._tables:
186 del self._tables[name]
187
188 data = self.storage.read()
189
190 # The database is uninitialized, there's nothing to do
191 if data is None:
192 return
193
194 # The table does not exist, there's nothing to do
195 if name not in data:
196 return
197
198 # Remove the table from the data dict
199 del data[name]
200
201 # Store the updated data back to the storage
202 self.storage.write(data)
203
204 @property
205 def storage(self) -> Storage:

Callers 1

test_drop_tableFunction · 0.95

Calls 2

readMethod · 0.45
writeMethod · 0.45

Tested by 1

test_drop_tableFunction · 0.76