ADO.NET Provider for Twitter

Build 21.0.7930

SELECT INTO ステートメント

SELECT INTO ステートメントを使って、書式付きデータをファイルにエクスポートできます。

SQL クエリを使ったデータのエクスポート

次のクエリは、comma-separated values(CSV)ファイルフォーマットにデータをエクスポートします。

C#

String connectionString = "InitiateOAuth=GETANDREFRESH;";

using (TwitterConnection connection = new TwitterConnection(connectionString)) {
  TwitterCommand cmd = new TwitterCommand("SELECT From_User_Name, Text INTO [csv://Tweets.txt] FROM [Tweets] WHERE From_User_Name = 'twitter' ", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "InitiateOAuth=GETANDREFRESH;" 

Using connection As New TwitterConnection(connectionString)
  Dim cmd As New TwitterCommand("SELECT From_User_Name, Text INTO [csv://Tweets.txt] FROM [Tweets] WHERE From_User_Name = 'twitter'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using
URI で他のファイルフォーマットを指定できます。以下の例は、tab-separated values(TSV)にエクスポートします。

C#

String connectionString = "InitiateOAuth=GETANDREFRESH;";

using (TwitterConnection connection = new TwitterConnection(connectionString)) {
  TwitterCommand cmd = new TwitterCommand("SELECT * INTO [Tweets] IN [csv://filename=c:/Tweets.csv;delimiter=tab] FROM [Tweets] WHERE From_User_Name = 'twitter'", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "InitiateOAuth=GETANDREFRESH;" 

Using connection As New TwitterConnection(connectionString)
  Dim cmd As New TwitterCommand("SELECT * INTO [Tweets] IN [csv://filename=c:/Tweets.csv;delimiter=tab] FROM [Tweets] WHERE From_User_Name = 'twitter'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using

Copyright (c) 2021 CData Software, Inc. - All rights reserved.
Build 21.0.7930