ODBC Driver for Google Calendar

Build 23.0.8839

データのクエリ

接続 後、SQL ステートメントを実行して結果を取得できます。

SELECT プロシージャ

sqlQuery 関数を使って、クエリを実行できます。デフォルトでは、すべての結果を単一のデータフレームとして返します。これは小さな結果セットに向いています。

results <- sqlQuery(cnx, "SELECT Id, Description FROM MyCalendar WHERE Status = 'confirmed'")
for (row in 1:nrow(results)) {
    cat(paste("Id = ", results[row,]$Id, "\n"))
    cat(paste("Description = ", results[row,]$Description, "\n"))
}

結果の反復処理

より大きな結果セットの場合、sqlQuery は結果セット全体をメモリに格納する代わりにバッチで結果を返すことができます。結果が残っていない場合やエラーが発生した場合は、sqlQuery およびsqlGetResults はデータフレームの代わりに整数のエラーコードを返します。

results <- sqlQuery(cnx, "SELECT Id, Description FROM MyCalendar WHERE Status = 'confirmed'", max = 1000)
while (is.data.frame(results)) {
    for (row in 1:nrow(results)) {
        cat(paste("Id = ", results[row,]$Id))
        cat(paste("Description = ", results[row,]$Description))
    }
    rows <- sqlGetResults(cnx, max = 1000)
}

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 23.0.8839