製品をチェック

無償トライアル:

無償トライアルへ

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

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 インターフェースで連携。

データ連携でお困りですか?

お問い合わせ

PyCharm でのCData ODBC Driver for ADLS の使用


CData ODBC Driver for ADLS を使用して、ODBC データソースとしてPyCharm からAzure Data Lake Storage に接続します。


azuredatalake ロゴ画像
odbc ロゴ画像

ODBC

PyCharm ロゴ画像

CData ODBC Drivers は、ODBC ドライバーをサポートするあらゆる環境から利用可能です。本記事では、PyCharm からのCData ODBC Driver for ADLS の利用を説明します。CData ODBC Deriver をデータソースとして設定する方法、データソースをクエリして結果を表示するためのPyCharm の簡単なコードを含みます。

はじめに、このチュートリアルではCData ODBC Driver for ADLS とPyCharm が、既にインストールされていることを前提としています。

Pyodbc をプロジェクトに追加

以下のステップに従って、pyodbc モジュールをプロジェクトに追加します。

  1. File]->[Settings]とクリックして[project settings]ウィンドウを開きます。
  2. Project: YourProjectName]メニューから[Project Interpreter]をクリックします。
  3. pyodbc を追加するため、+ ボタンをクリックしてpyodbc と入力します。
  4. Install Package]をクリックしてpyodbc をインストールします。

Azure Data Lake Storage への接続

これで、ODBC 接続文字列またはDSN で接続できます。お客様のOS でDSN を作成するためのガイドについては、CData ドライバードキュメントの[はじめに]セクションを参照してください。

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.

以下はDSN の構文です。

[CData ADLS Source] Driver = CData ODBC Driver for ADLS Description = My Description Schema = ADLSGen2 Account = myAccount FileSystem = myFileSystem AccessKey = myAccessKey

Azure Data Lake Storage へのクエリの実行

Cursor をインスタンス化し、Cursor クラスのexecute メソッドを使用してSQL ステートメントを実行します。

import pyodbc cnxn = pyodbc.connect('DRIVER={CData ODBC Driver for ADLS};Schema = ADLSGen2;Account = myAccount;FileSystem = myFileSystem;AccessKey = myAccessKey;') cursor = cnxn.cursor() cursor.execute("SELECT FullPath, Permission FROM Resources WHERE Type = 'FILE'") rows = cursor.fetchall() for row in rows: print(row.FullPath, row.Permission)

CData ODBC Driver を使用してPyCharm でAzure Data Lake Storage に接続すると、Azure Data Lake Storage にアクセスできるPython アプリケーションを標準データベースのように構築できるようになります。このチュートリアルに関する質問、コメント、フィードバックがある場合には、support@cdata.com までご連絡ください。