Cmdlets for Gmail

Build 20.0.7654

SELECT INTO ステートメント

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

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

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

C#

String connectionString = "user=myuseraccount;password=mypassword;";

using (GmailConnection connection = new GmailConnection(connectionString)) {
  GmailCommand cmd = new GmailCommand("SELECT Id, MessageBody INTO [csv://Inbox.txt] FROM [Inbox] WHERE From = 'test@test.com' ", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "user=myuseraccount;password=mypassword;" 

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

C#

String connectionString = "user=myuseraccount;password=mypassword;";

using (GmailConnection connection = new GmailConnection(connectionString)) {
  GmailCommand cmd = new GmailCommand("SELECT * INTO [Inbox] IN [csv://filename=c:/Inbox.csv;delimiter=tab] FROM [Inbox] WHERE From = 'test@test.com'", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "user=myuseraccount;password=mypassword;" 

Using connection As New GmailConnection(connectionString)
  Dim cmd As New GmailCommand("SELECT * INTO [Inbox] IN [csv://filename=c:/Inbox.csv;delimiter=tab] FROM [Inbox] WHERE From = 'test@test.com'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using

Copyright (c) 2020 CData Software, Inc. - All rights reserved.
Build 20.0.7654