

 Amazon Redshift は、パッチ 198 以降、新しい Python UDF の作成をサポートしなくなります。既存の Python UDF は、2026 年 6 月 30 日まで引き続き機能します。詳細については、[ブログ記事](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)を参照してください。

# Amazon Redshift Python コネクタの API リファレンス
<a name="python-api-reference"></a>

Amazon Redshift Python コネクタ API オペレーションの説明は次のとおりです。

## redshift\$1connector
<a name="python-api-redshift_connector"></a>

`redshift_connector`API オペレーションの説明は次のとおりです。

`connect(user, database, password[, port, …])`  
Amazon Redshift クラスターへの接続を確立します。この関数は、ユーザー入力を検証し、必要に応じて アイデンティティプロバイダープラグインを使用して認証し、接続オブジェクトを作成します。

`apilevel`  
現在サポートされている DBAPI レベルは「2.0」です。

`paramstyle``str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str`  
グローバルに使用するデータベース API パラメータスタイル。

## 接続
<a name="python-api-connection"></a>

Amazon Redshift Python コネクタの接続 API オペレーションの説明は次のとおりです。

`__init__(user, password, database[, host, …])`  
生の接続オブジェクトを初期化します。

`cursor`  
この接続にバインドされたカーソルオブジェクトを作成します。

`commit`  
現在のデータベーストランザクションをコミットします。

`rollback`  
現在のデータベーストランザクションをロールバックします。

`close`  
データベース接続を閉じます。

`execute(cursor, operation, vals)`  
指定された SQL コマンドを実行します。`redshift_connector.paramstyle`の値に応じて、パラメータをシーケンスまたはマッピングとして提供することができます。

`run(sql[, stream])`  
指定された SQL コマンドを実行します。オプションで、COPY コマンドで使用するストリーミングを指定することができます。

`xid(format_id, global_transaction_id, …)`  
トランザクション ID を作成します。`global_transaction_id`パラメータのみが postgres で使用されます。format\$1id と branch\$1qualifier は postgres では使用されません。`global_transaction_id`は、タプル(`format_id`、`global_transaction_id`、`branch_qualifier`)を返す postgres がサポートする任意の文字列識別子とすることができます。

`tpc_begin(xid)`  
フォーマット ID、グローバルトランザクション ID、ブランチクオリファイアで構成されるトランザクション ID `xid`で、TPC トランザクションを開始します。

`tpc_prepare`  
.tpc\$1begin で開始されたトランザクションの最初のフェーズを実行します。

`tpc_commit([xid])`  
引数なしで呼び出された場合、.tpc\$1commit は、以前に.tpc\$1prepare () で準備された TPC トランザクションをコミットします。

`tpc_rollback([xid])`  
引数なしで呼び出されると、.tpc\$1rollback は TPC トランザクションをロールバックします。

`tpc_recover`  
.tpc\$1commit (xid) または.tpc\$1rollback (xid) での使用に適した保留中のトランザクション ID のリストを返します。

## カーソル
<a name="python-api-cursor"></a>

カーソル API オペレーションの説明は次のとおりです。

`__init__(connection[, paramstyle])`  
生のカーソルオブジェクトを初期化します。

`insert_data_bulk(filename, table_name, parameter_indices, column_names, delimiter, batch_size)`  
一括 INSERT ステートメントを実行します。

`execute(operation[, args, stream, …])`  
データベースオペレーションを実行します。

`executemany(operation, param_sets)`  
データベースオペレーションを準備し、指定されたすべてのパラメータシーケンスまたはマッピングに対して実行します。

`fetchone`  
クエリの結果セットの次の行を取得します。

`fetchmany([num])`  
クエリ結果の次の行のセットを取得します。

`fetchall`  
クエリ結果の残りのすべての行を取得します。

`close`  
今すぐカーソルを閉じます。

`__iter__`  
カーソルオブジェクトを反復処理して、クエリから行を取得できます。

`fetch_dataframe([num])`  
最後のクエリ結果のデータフレームを返します。

`write_dataframe(df, table)`  
同じ構造データフレームを Amazon Redshift データベースに書き込みます。

`fetch_numpy_array([num])`  
最後のクエリ結果の NumPy 配列を返します。

`get_catalogs`  
Amazon Redshift は、1 つの接続で複数のカタログをサポートしていません。Amazon Redshift は現在のカタログのみを返します。

`get_tables([catalog, schema_pattern, …])`  
システム内でユーザー定義された固有のパブリックテーブルを返します。

`get_columns([catalog, schema_pattern, …])`  
Amazon Redshift データベース内の特定のテーブルのすべての列のリストを返します。

## AdfsCredentials プロバイダープラグイン
<a name="python-adfs-credentials-plugin"></a>

Amazon Redshift Python コネクタの AdfsCredentials プロバイダープラグイン API オペレーションの構文を次に示します。

```
redshift_connector.plugin.AdfsCredentialsProvider()
```

## AzureCredentials プロバイダープラグイン
<a name="python-azure-credentials-plugin"></a>

Amazon Redshift Python コネクタの AzureCredentials プロバイダープラグイン API オペレーションの構文を次に示します。

```
redshift_connector.plugin.AzureCredentialsProvider()
```

## ブラウザ AzureCredentials プロバイダープラグイン
<a name="python-browser-azure-credentials-plugin"></a>

Amazon Redshift Python コネクタのBrowserAzureCredentials プロバイダープラグイン API オペレーションの構文を以下に示します。

```
redshift_connector.plugin.BrowserAzureCredentialsProvider()
```

## BrowserSamlCredentials プロバイダープラグイン
<a name="python-browser-saml-credentials-plugin"></a>

Amazon Redshift Python コネクタの BrowserSamlCredentials プロバイダープラグイン API オペレーションの構文は以下のとおりです。

```
redshift_connector.plugin.BrowserSamlCredentialsProvider()
```

## Oktacredentials プロバイダープラグイン
<a name="python-okta-credentials-plugin"></a>

Amazon Redshift Python コネクタの OktaCredentials プロバイダープラグイン API オペレーションの構文を次に示します。

```
redshift_connector.plugin.OktaCredentialsProvider()
```

## PingCredentials プロバイダープラグイン
<a name="python-ping-credentials-plugin"></a>

Amazon Redshift Python コネクタの PingCredentials プロバイダー プラグイン API オペレーションの構文を次に示します。

```
redshift_connector.plugin.PingCredentialsProvider()
```

## SamlCredentials プロバイダープラグイン
<a name="python-saml-credentials-plugin"></a>

Amazon Redshift Python コネクタの SamlCredentials プロバイダープラグイン API オペレーションの構文を次に示します。

```
redshift_connector.plugin.SamlCredentialsProvider()
```