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

Method tables

tinydb/database.py:135–161  ·  view source on GitHub ↗

Get the names of all tables in the database. :returns: a set of table names

(self)

Source from the content-addressed store, hash-verified

133 return table
134
135 def tables(self) -> Set[str]:
136 """
137 Get the names of all tables in the database.
138
139 :returns: a set of table names
140 """
141
142 # TinyDB stores data as a dict of tables like this:
143 #
144 # {
145 # '_default': {
146 # 0: {document...},
147 # 1: {document...},
148 # },
149 # 'table1': {
150 # ...
151 # }
152 # }
153 #
154 # To get a set of table names, we thus construct a set of this main
155 # dict which returns a set of the dict keys which are the table names.
156 #
157 # Storage.read() may return ``None`` if the database file is empty,
158 # so we need to consider this case to and return an empty set in this
159 # case.
160
161 return set(self.storage.read() or {})
162
163 def drop_tables(self) -> None:
164 """

Callers 4

__repr__Method · 0.95
test_drop_tableFunction · 0.95
test_tables_listFunction · 0.80
test_persist_tableFunction · 0.80

Calls 2

setFunction · 0.85
readMethod · 0.45

Tested by 3

test_drop_tableFunction · 0.76
test_tables_listFunction · 0.64
test_persist_tableFunction · 0.64