本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
適用於 Ruby 的 SDK 的 Aurora 範例
下列程式碼範例示範如何使用 適用於 Ruby 的 AWS SDK 搭配 Aurora 執行動作和實作常見案例。
每個範例均包含完整原始碼的連結,您可在連結中找到如何設定和執行內容中程式碼的相關指示。
主題
開始使用
下列程式碼範例示範如何開始使用 Aurora。
- SDK for 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 詳細資訊,請參閱《適用於 Ruby 的 AWS SDK API 參考》中的 DescribeDBClusters。
-