Drop a table from the database, along with all rows therein and related indexes. Args: name: the name of the table to drop. keyspace: the keyspace where the table resides. If not specified, the database working keyspace is assumed.
(
self,
name: str,
*,
keyspace: str | None = None,
if_exists: bool | None = None,
table_admin_timeout_ms: int | None = None,
request_timeout_ms: int | None = None,
timeout_ms: int | None = None,
)
| 3817 | logger.info(f"finished dropIndex('{name}')") |
| 3818 | |
| 3819 | async def drop_table( |
| 3820 | self, |
| 3821 | name: str, |
| 3822 | *, |
| 3823 | keyspace: str | None = None, |
| 3824 | if_exists: bool | None = None, |
| 3825 | table_admin_timeout_ms: int | None = None, |
| 3826 | request_timeout_ms: int | None = None, |
| 3827 | timeout_ms: int | None = None, |
| 3828 | ) -> None: |
| 3829 | """ |
| 3830 | Drop a table from the database, along with all rows therein and related indexes. |
| 3831 | |
| 3832 | Args: |
| 3833 | name: the name of the table to drop. |
| 3834 | keyspace: the keyspace where the table resides. If not specified, |
| 3835 | the database working keyspace is assumed. |
| 3836 | if_exists: if passed as True, trying to drop a non-existing table |
| 3837 | will not error, just silently do nothing instead. If not provided, |
| 3838 | the API default behaviour will hold. |
| 3839 | table_admin_timeout_ms: a timeout, in milliseconds, to impose on the |
| 3840 | underlying API request. If not provided, this object's defaults apply. |
| 3841 | (This method issues a single API request, hence all timeout parameters |
| 3842 | are treated the same.) |
| 3843 | request_timeout_ms: an alias for `table_admin_timeout_ms`. |
| 3844 | timeout_ms: an alias for `table_admin_timeout_ms`. |
| 3845 | |
| 3846 | Example: |
| 3847 | >>> # NOTE: may require slight adaptation to an async context. |
| 3848 | >>> |
| 3849 | >>> asyncio.run(async_database.list_table_names()) |
| 3850 | ['fighters', 'games'] |
| 3851 | >>> asyncio.run(async_database.drop_table("fighters")) |
| 3852 | >>> asyncio.run(async_database.list_table_names()) |
| 3853 | ['games'] |
| 3854 | >>> # not erroring because of if_exists: |
| 3855 | >>> asyncio.run(async_database.drop_table("fighters", if_exists=True)) |
| 3856 | """ |
| 3857 | |
| 3858 | _table_admin_timeout_ms, _ta_label = _select_singlereq_timeout_ta( |
| 3859 | timeout_options=self.api_options.timeout_options, |
| 3860 | table_admin_timeout_ms=table_admin_timeout_ms, |
| 3861 | request_timeout_ms=request_timeout_ms, |
| 3862 | timeout_ms=timeout_ms, |
| 3863 | ) |
| 3864 | _keyspace = keyspace or self.keyspace |
| 3865 | dt_options: dict[str, bool] |
| 3866 | if if_exists is not None: |
| 3867 | dt_options = {"ifExists": if_exists} |
| 3868 | else: |
| 3869 | dt_options = {} |
| 3870 | driver_commander = self._get_driver_commander(keyspace=_keyspace) |
| 3871 | dt_payload = { |
| 3872 | "dropTable": { |
| 3873 | k: v |
| 3874 | for k, v in { |
| 3875 | "name": name, |
| 3876 | "options": dt_options, |
nothing calls this directly
no test coverage detected