製品をチェック

無償トライアル:

無償トライアルへ

製品の情報と無償トライアルへ:

Azure Data Lake Storage ODBC Driver

Azure Data Lake Storage ODBC Driver を使って、ODBC 接続をサポートするあらゆるアプリケーション・ツールからAzure Data Lake Storage にデータ連携。

Azure Data Lake Storage にデータベースと同感覚でアクセスして、Azure Data Lake Storage データに使い慣れたODBC インターフェースで連携。

Delphi のAzure Data Lake Storage データへのデータバインドコントロール


標準のデータアクセスコンポーネントとコントロールを備えたDelphi のAzure Data Lake Storage にデータバインドします。


古川えりか
コンテンツスペシャリスト

CData ODBC Driver for ADLS は、ODBC 標準をサポートし、ライブAzure Data Lake Storage データとビジュアルフォームデザイナおよびDelphi の他のラピッド開発ツールとの統合を可能にします。ODBC ドライバーは、データベース開発用のシングルAPI を提供することにより、Delphi のような単一のコードベースを共有するアプリケーションのデータアクセス戦略を簡素化します。この記事では、Azure Data Lake Storage に接続してシンプルなVisual Component Library (VCL) アプリケーションおよびDelphi コードからデータをクエリする方法を説明します。

Azure Data Lake Storage データへの新しいFireDAC 接続を作成します。

未指定の場合は、初めにODBC DSN (data source name) で接続プロパティを指定します。ドライバーのインストールの最後にアドミニストレーターが開きます。Microsoft ODBC Data Source Administrator を使用して、ODBC DSN を作成および構成できます。

Authenticating to a Gen 1 DataLakeStore Account

Gen 1 uses OAuth 2.0 in Azure AD for authentication.

For this, an Active Directory web application is required. You can create one as follows:

  1. Sign in to your Azure Account through the .
  2. Select "Azure Active Directory".
  3. Select "App registrations".
  4. Select "New application registration".
  5. Provide a name and URL for the application. Select Web app for the type of application you want to create.
  6. Select "Required permissions" and change the required permissions for this app. At a minimum, "Azure Data Lake" and "Windows Azure Service Management API" are required.
  7. Select "Key" and generate a new key. Add a description, a duration, and take note of the generated key. You won't be able to see it again.

To authenticate against a Gen 1 DataLakeStore account, the following properties are required:

  • Schema: Set this to ADLSGen1.
  • Account: Set this to the name of the account.
  • OAuthClientId: Set this to the application Id of the app you created.
  • OAuthClientSecret: Set this to the key generated for the app you created.
  • TenantId: Set this to the tenant Id. See the property for more information on how to acquire this.
  • Directory: Set this to the path which will be used to store the replicated file. If not specified, the root directory will be used.

Authenticating to a Gen 2 DataLakeStore Account

To authenticate against a Gen 2 DataLakeStore account, the following properties are required:

  • Schema: Set this to ADLSGen2.
  • Account: Set this to the name of the account.
  • FileSystem: Set this to the file system which will be used for this account.
  • AccessKey: Set this to the access key which will be used to authenticate the calls to the API. See the property for more information on how to acquire this.
  • Directory: Set this to the path which will be used to store the replicated file. If not specified, the root directory will be used.

以下のステップに従ってData Explorer を使用し、Azure Data Lake Storage へのFireDAC 接続を作成できます。

  1. 新しいVCL Forms アプリケーションの[Data Explorer]で[FireDAC]ノードを展開します。
  2. [Data Explorer]で[ODBC Data Source]ノードを右クリックします。
  3. [Add New Connection]をクリックします。
  4. 接続の名前を入力します。
  5. 表示される[FireDAC Connection Editor]で、[DataSource]プロパティをODBC DSN for ADLS の名前に設定します。
A FireDAC connection to the ODBC data source.(Salesforce is shown.)

Azure Data Lake Storage データに接続できるVCL アプリケーションの作成

以下のステップに従って、クエリの結果をグリッドに表示するシンプルなVCL アプリケーションからAzure Data Lake Storage のクエリの実行を開始します。

  1. TFDConnection コンポーネントフォームにドロップし、以下のプロパティを設定します。

    • ConnectionDefName:Azure Data Lake Storage へのFireDAC 接続を選択します。
    • Connected:メニューから[True]を選択し、表示されるダイアログで資格情報を入力します。
  2. TFDQuery コンポーネントをフォームにドロップし、以下のプロパティを設定します。

    • Connection:コンポーネントがまだ指定されていない場合は、このプロパティを[TFDConnection]コンポーネントに設定します。
    • SQL:[SQL]プロパティ内のボタンをクリックし、クエリを入力します。例:

      SELECT FullPath, Permission FROM Resources WHERE Type = 'FILE'
    • Active:このプロパティをtrue に設定します。
  3. TDataSource コンポーネントをフォームにドロップし、以下のプロパティを設定します。

    • DataSet:このプロパティのメニューで、TFDQuery コンポーネントの名前を選択します。
  4. TDBGrid コントロールをフォームにドロップし、以下のプロパティを設定します。

    • DataSource:TDataSource の名前を選択します。
  5. 実行時エラーを回避するために、TFDGUIxWaitCursor をフォームにドロップします。
Components in FireDAC used to databind an editable grid to the data source.(Salesforce is shown.)

FireDAC コンポーネントを使用してAzure Data Lake Storage へのコマンドを実行

TFDConnection およびTFQuery コンポーネントを使用してAzure Data Lake Storage へのクエリを実行できます。このセクションでは、TFQuery コンポーネントを使用してクエリを実行するAzure Data Lake Storage 固有の例を示します。

Azure Data Lake Storage データに接続

データソースに接続するには、TFDConnection コンポーネントの[Connected]プロパティをtrue に設定します。コードでも同じプロパティを設定できます。

FDConnection1.ConnectionDefName := 'myazuredatalake'; FDConnection1.Connected := true;

パラメータクエリの作成

パラメータ化されたリソースはパフォーマンスを向上させることができます。ステートメントの準備は、システムリソースと時間の面でコストがかかります。ステートメントの準備中、接続がアクティブで開いている必要があるためです。FireDACはデフォルトで、同じクエリが何度もリコンパイルされないようにクエリを準備します。ステートメントの準備を無効にするには、ResourceOptions.DirectExecute を[True]に設定します。クエリを一回だけ実行する必要がある場合などに設定します。

クエリの実行

select クエリなど、結果セットを返すクエリを実行するには、Open メソッドを使用します。Open メソッドは、クエリを実行して結果セットを返し、それを開きます。クエリが結果セットを生成しない場合、Open メソッドはエラーを返します。

FDQuery1.Open('select * from Resources where Type = :Type',['FILE']);