O Amazon Redshift não permitirá mais a criação de funções definidas pelo usuário (UDFs) do Python a partir de 1.º de novembro de 2025. Se quiser usar UDFs do Python, você deve criá-las antes dessa data. As UDFs do Python existentes continuarão a funcionar normalmente. Para ter mais informações, consulte a publicação de blog .
Usar ListDatabases com um SDK da AWS
O código de exemplo a seguir mostra como usar ListDatabases.
- Java
-
- SDK para Java 2.x
-
/**
* Lists all databases asynchronously for the specified cluster, database user, and database.
* @param clusterId the identifier of the cluster to list databases for
* @param dbUser the database user to use for the list databases request
* @param database the database to list databases for
* @return a {@link CompletableFuture} that completes when the database listing is complete, or throws a {@link RuntimeException} if there was an error
*/
public CompletableFuture<Void> listAllDatabasesAsync(String clusterId, String dbUser, String database) {
ListDatabasesRequest databasesRequest = ListDatabasesRequest.builder()
.clusterIdentifier(clusterId)
.dbUser(dbUser)
.database(database)
.build();
// Asynchronous paginator for listing databases.
ListDatabasesPublisher databasesPaginator = getAsyncDataClient().listDatabasesPaginator(databasesRequest);
CompletableFuture<Void> future = databasesPaginator.subscribe(response -> {
response.databases().forEach(db -> {
logger.info("The database name is {} ", db);
});
});
// Return the future for asynchronous handling.
return future.exceptionally(exception -> {
throw new RuntimeException("Failed to list databases: " + exception.getMessage(), exception);
});
}
Para ver uma lista completa dos Guias do desenvolvedor e exemplos de código do SDK da AWS, consulte Usar este serviço com um AWS SDK. Este tópico também inclui informações sobre como começar e detalhes sobre versões anteriores do SDK.