今すぐお試しください!

製品の詳細CData FireDAC Components for Amazon Athena を確認して、無償評価版をダウンロード:

今すぐダウンロード

Build a Simple VCL Application for Athena Data

How to build a simple VCL Application to view Athena data in RAD Studio using the CData FireDAC Components for Athena.

Embarcadero RAD Studio provides a development environment for Delphi and C++Builder applications. With the CData FireDAC Components for Athena, you gain access to live Athena data within RAD Studio, abstracting the data into tables, views, and stored procedures that can be used to both retrieve and update Athena data. This article will walk through connecting to Athena and creating a simple VCL application with the Form Designer.

Creating a VCL Application for Athena Data

The following instructions show how to use the Form Designer to create a simple VCL Forms application that shows the basic FireDAC objects needed to connect to Athena from any application.

The following example populates a TDBGrid control.

  1. Create a new VCL Forms Application.
  2. Drop a TFDPhysAmazonAthenaDriverLink and TFDConnection object onto the form.
  3. Double-click the TFDConnection object. The FireDAC Connection Editor is displayed. Select "CData.AmazonAthena" in the DriverId menu and configure the connection properties.

    Amazon Athena への接続

    Amazon Athena リクエストの認証には、アカウントの管理のクレデンシャルか、IAM ユーザーのカスタムPermission を設定します。 AccessKey にAccess Key Id、SecretKey にはSecret Access Key を設定します。

    Note: AWS アカウントアドミニストレータとしてアクセスできる場合でも、AWS サービスへの接続にはIAM ユーザークレデンシャルを使用することが推奨されます。

    Access Key の取得

    IAM ユーザーのクレデンシャル取得は以下の通り:

    1. IAM コンソールにログイン
    2. Navigation ペインでUsers を選択。
    3. To create or manage the access keys for a user, select the user and then select the Security Credentials tab.

    To obtain the credentials for your AWS root account, follow the steps below:

    1. Sign into the AWS Management console with the credentials for your root account.
    2. Select your account name or number and select My Security Credentials in the menu that is displayed.
    3. Click Continue to Security Credentials and expand the Access Keys section to manage or create root account access keys.

    Authenticating from an EC2 Instance

    If you are using the CData Data Provider for Amazon Athena 2018 from an EC2 Instance and have an IAM Role assigned to the instance, you can use the IAM Role to authenticate. To do so, set UseEC2Roles to true and leave AccessKey and SecretKey empty. The CData Data Provider for Amazon Athena 2018 will automatically obtain your IAM Role credentials and authenticate with them.

    Authenticating as an AWS Role

    In many situations it may be preferable to use an IAM role for authentication instead of the direct security credentials of an AWS root user. An AWS role may be used instead by specifying the RoleARN. This will cause the CData Data Provider for Amazon Athena 2018 to attempt to retrieve credentials for the specified role. If you are connecting to AWS (instead of already being connected such as on an EC2 instance), you must additionally specify the AccessKey and SecretKey of an IAM user to assume the role for. Roles may not be used when specifying the AccessKey and SecretKey of an AWS root user.

    Authenticating with MFA

    For users and roles that require Multi-factor Authentication, specify the MFASerialNumber and MFAToken connection properties. This will cause the CData Data Provider for Amazon Athena 2018 to submit the MFA credentials in a request to retrieve temporary authentication credentials. Note that the duration of the temporary credentials may be controlled via the TemporaryTokenDuration (default 3600 seconds).

    Connecting to Amazon Athena

    In addition to the AccessKey and SecretKey properties, specify Database, S3StagingDirectory and Region. Set Region to the region where your Amazon Athena data is hosted. Set S3StagingDirectory to a folder in S3 where you would like to store the results of queries.

    If Database is not set in the connection, the data provider connects to the default database set in Amazon Athena.

  4. Drop a TFDQuery object onto the form and set the properties below:

    • Connection - Set this property to the TFDConnection object, if this object is not already specified.
    • SQL - Click the button in the SQL property and enter a query.
    • Active - Set this property to true.
  5. Drop a TDataSource object onto the form and set the following property:

    • DataSet - In the menu for this property, select the name of the TFDQuery object.
  6. Drop a TDBGrid control onto the form and set the following property:

    • DataSource - Select the name of the TDataSource.
  7. Drop a TFDGUIxWaitCursor onto the form. This is required to avoid a run-time error.

You now have an executable application that displays the results of the SQL Query set in the TFDQuery object.

 
 
ダウンロード