-------------------- Issues the supplied (parameterized) DROP statement to the Space and Time network, and report back success and details. Args: user (SXTUser): Authenticated user who will issue the command. If omitted, will use the default user, resource.user
(self, user:SXTUser = None, biscuits:list = None)
| 439 | |
| 440 | |
| 441 | def drop(self, user:SXTUser = None, biscuits:list = None): |
| 442 | """-------------------- |
| 443 | Issues the supplied (parameterized) DROP statement to the Space and Time network, and report back success and details. |
| 444 | |
| 445 | Args: |
| 446 | user (SXTUser): Authenticated user who will issue the command. If omitted, will use the default user, resource.user |
| 447 | biscuits (list): List of biscuits to include with the request, either as string biscuit tokens or as SXTBiscuit objects. If omitted, will use the class.biscuits list. Must contain DROP permissions. |
| 448 | |
| 449 | Returns: |
| 450 | bool: Success flag, True if the object was dropped. |
| 451 | object: other details supplied during the request, including API messaging. Typically a dict. |
| 452 | """ |
| 453 | self.logger.info(f'{"-"*15}\nDROPPING {self.resource_type.name}: {self.resource_name}...') |
| 454 | user = self.get_first_valid_user(user) |
| 455 | if not biscuits: biscuits = list(self.biscuits) |
| 456 | if biscuits == []: |
| 457 | raise SxTArgumentError('A biscuit with DROP must be included.', logger=self.logger) |
| 458 | objtype = 'TABLE' if self.resource_type.name.lower()=='table' else 'VIEW' |
| 459 | sql_text = f'DROP {objtype} {self.resource_name}' |
| 460 | success, results = user.base_api.sql_ddl(sql_text=sql_text, biscuits=biscuits, app_name=self.application_name) |
| 461 | if success: |
| 462 | self.logger.info(f' DROPPED: {self.resource_name}') |
| 463 | else: |
| 464 | self.logger.error(f'{self.resource_type.name} FAILED TO DROP with user {user.user_id}:\n{results}\n{sql_text}') |
| 465 | self.__lasterr__ = None if success else self.SXTExceptions.SxTQueryError(results) |
| 466 | return success, results |
| 467 | |
| 468 | |
| 469 | def select(self, sql_text:str = '', columns:list = ['*'], user:SXTUser = None, biscuits:list = None, row_limit:int = 50) -> tuple[bool, dict]: |