使用 SDK for Ruby 的 Aurora 範例 - AWS SDK 適用於 Ruby

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

使用 SDK for Ruby 的 Aurora 範例

下列程式碼範例示範如何使用 AWS SDK for Ruby 搭配 Aurora 來執行動作和實作常見案例。

每個範例都包含完整原始程式碼的連結,您可以在其中找到如何在內容中設定和執行程式碼的指示。

開始使用

下列程式碼範例示範如何開始使用 Aurora。

SDK 適用於 Ruby
注意

還有更多功能 GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

require 'aws-sdk-rds' # Creates an Amazon RDS client for the AWS Region rds = Aws::RDS::Client.new puts 'Listing clusters in this AWS account...' # Calls the describe_db_clusters method to get information about clusters resp = rds.describe_db_clusters(max_records: 20) # Checks if any clusters are found and prints the appropriate message if resp.db_clusters.empty? puts 'No clusters found!' else # Loops through the array of cluster objects and prints the cluster identifier resp.db_clusters.each do |cluster| puts "Cluster identifier: #{cluster.db_cluster_identifier}" end end
  • 如需API詳細資訊,請參閱 AWS SDK for Ruby API參考中的 DescribeDBClusters