데이터베이스 삭제 - Amazon Timestream

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

데이터베이스 삭제

다음 코드 조각을 사용하여 데이터베이스를 삭제할 수 있습니다.

참고

이러한 코드 조각은 의 전체 샘플 애플리케이션을 기반으로 합니다GitHub. 샘플 애플리케이션을 시작하는 방법에 대한 자세한 내용은 섹션을 참조하세요샘플 애플리케이션.

Java
public void deleteDatabase() { System.out.println("Deleting database"); final DeleteDatabaseRequest deleteDatabaseRequest = new DeleteDatabaseRequest(); deleteDatabaseRequest.setDatabaseName(DATABASE_NAME); try { DeleteDatabaseResult result = amazonTimestreamWrite.deleteDatabase(deleteDatabaseRequest); System.out.println("Delete database status: " + result.getSdkHttpMetadata().getHttpStatusCode()); } catch (final ResourceNotFoundException e) { System.out.println("Database " + DATABASE_NAME + " doesn't exist = " + e); throw e; } catch (final Exception e) { System.out.println("Could not delete Database " + DATABASE_NAME + " = " + e); throw e; } }
Java v2
public void deleteDatabase() { System.out.println("Deleting database"); final DeleteDatabaseRequest deleteDatabaseRequest = new DeleteDatabaseRequest(); deleteDatabaseRequest.setDatabaseName(DATABASE_NAME); try { DeleteDatabaseResult result = amazonTimestreamWrite.deleteDatabase(deleteDatabaseRequest); System.out.println("Delete database status: " + result.getSdkHttpMetadata().getHttpStatusCode()); } catch (final ResourceNotFoundException e) { System.out.println("Database " + DATABASE_NAME + " doesn't exist = " + e); throw e; } catch (final Exception e) { System.out.println("Could not delete Database " + DATABASE_NAME + " = " + e); throw e; } }
Go
deleteDatabaseInput := &timestreamwrite.DeleteDatabaseInput{ DatabaseName: aws.String(*databaseName), } _, err = writeSvc.DeleteDatabase(deleteDatabaseInput) if err != nil { fmt.Println("Error:") fmt.Println(err) } else { fmt.Println("Database deleted:", *databaseName) }
Python
def delete_database(self): print("Deleting Database") try: result = self.client.delete_database(DatabaseName=Constant.DATABASE_NAME) print("Delete database status [%s]" % result['ResponseMetadata']['HTTPStatusCode']) except self.client.exceptions.ResourceNotFoundException: print("database [%s] doesn't exist" % Constant.DATABASE_NAME) except Exception as err: print("Delete database failed:", err)
Node.js

다음 조각은 JavaScript v3에 를 사용합니다 AWS SDK. 클라이언트를 설치하는 방법과 사용량에 대한 자세한 내용은 JavaScript v3SDK용 Timestream Write Client - AWS를 참조하세요.

클래스 DeleteDatabaseCommand 및 도 참조하세요DeleteDatabase.

import { TimestreamWriteClient, DeleteDatabaseCommand } from "@aws-sdk/client-timestream-write"; const writeClient = new TimestreamWriteClient({ region: "us-east-1" }); const params = { DatabaseName: "testDbFromNode" }; const command = new DeleteDatabaseCommand(params); try { const data = await writeClient.send(command); console.log("Deleted database"); } catch (error) { if (error.code === 'ResourceNotFoundException') { console.log(`Database ${params.DatabaseName} doesn't exists.`); } else { console.log("Delete database failed.", error); throw error; } }

다음 코드 조각은 JavaScript V2 스타일에 대해 를 AWS SDK 사용합니다. 이는 Node.js 샘플 Amazon Timestream의 샘플 애플리케이션을 기반으로 LiveAnalytics 합니다 GitHub.

async function deleteDatabase() { console.log("Deleting Database"); const params = { DatabaseName: constants.DATABASE_NAME }; const promise = writeClient.deleteDatabase(params).promise(); await promise.then( function (data) { console.log("Deleted database"); }, function(err) { if (err.code === 'ResourceNotFoundException') { console.log(`Database ${params.DatabaseName} doesn't exists.`); } else { console.log("Delete database failed.", err); throw err; } } ); }
.NET
public async Task DeleteDatabase() { Console.WriteLine("Deleting database"); try { var deleteDatabaseRequest = new DeleteDatabaseRequest { DatabaseName = Constants.DATABASE_NAME }; DeleteDatabaseResponse response = await writeClient.DeleteDatabaseAsync(deleteDatabaseRequest); Console.WriteLine($"Database {Constants.DATABASE_NAME} delete request status:{response.HttpStatusCode}"); } catch (ResourceNotFoundException) { Console.WriteLine($"Database {Constants.DATABASE_NAME} does not exists"); } catch (Exception e) { Console.WriteLine("Exception while deleting database:" + e.ToString()); } }