Get access to a specific table. If the table hasn't been accessed yet, a new table instance will be created using the :attr:`~tinydb.database.TinyDB.table_class` class. Otherwise, the previously created table instance will be returned. All further options b
(self, name: str, **kwargs)
| 109 | return '<{} {}>'.format(type(self).__name__, ', '.join(args)) |
| 110 | |
| 111 | def table(self, name: str, **kwargs) -> Table: |
| 112 | """ |
| 113 | Get access to a specific table. |
| 114 | |
| 115 | If the table hasn't been accessed yet, a new table instance will be |
| 116 | created using the :attr:`~tinydb.database.TinyDB.table_class` class. |
| 117 | Otherwise, the previously created table instance will be returned. |
| 118 | |
| 119 | All further options besides the name are passed to the table class which |
| 120 | by default is :class:`~tinydb.table.Table`. Check its documentation |
| 121 | for further parameters you can pass. |
| 122 | |
| 123 | :param name: The name of the table. |
| 124 | :param kwargs: Keyword arguments to pass to the table class constructor |
| 125 | """ |
| 126 | |
| 127 | if name in self._tables: |
| 128 | return self._tables[name] |
| 129 | |
| 130 | table = self.table_class(self.storage, name, **kwargs) |
| 131 | self._tables[name] = table |
| 132 | |
| 133 | return table |
| 134 | |
| 135 | def tables(self) -> Set[str]: |
| 136 | """ |
no outgoing calls