delete_database_entry#
- teamworksams.database_main.delete_database_entry(database_entry_id: int, url: str, username: str | None = None, password: str | None = None, client: AMSClient | None = None) bool [source]#
Delete a specific database entry from an AMS instance.
Sends a request to the AMS API to delete the database entry with the specified ID, returning True if successful. Requires valid credentials and a valid entry ID, typically obtained from get_database. See Database Operations for database workflows.
- Parameters:
database_entry_id (int) – ID of the database entry to delete. Must be a non-negative integer (e.g., 386197).
url (str) – AMS instance URL (e.g., ‘https://example.smartabase.com/site’). Must include a valid site name.
username (Optional[str]) – Username for authentication. If None, uses
AMS_USERNAME
orkeyring
credentials. Defaults to None.password (Optional[str]) – Password for authentication. If None, uses
AMS_PASSWORD
orkeyring
credentials. Defaults to None.client (AMSClient, optional) – Pre-authenticated client from
get_client()
. If None, a new client is created. Defaults to None.
- Returns:
True if the entry is successfully deleted.
- Return type:
bool
- Raises:
AMSError – If authentication fails, the API request fails, or the deletion fails.
ValueError – If
database_entry_id
is negative or not an integer.
Examples
>>> from teamworksams import delete_database_entry >>> result = delete_database_entry( ... database_entry_id=386197, ... url = "https://example.smartabase.com/site", ... username = "user", ... password = "pass" ... ) >>> print(result) ✔ Successfully deleted database entry 386197.
Additional Notes#
The
database_entry_id
must be a valid ID from the AMS database form, obtainable via get_database(); invalid IDs raiseAMSError
.Use a pre-authenticated AMSClient() with
client
to reduce authentication overhead in batch deletions.Deletion is permanent; ensure correct ID before executing.
See Also#
get_database(): For retrieving entry IDs.
Database Operations: Database workflows.