> ## Documentation Index
> Fetch the complete documentation index at: https://cndoc-langchain.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Glue 目录集成

> 使用 LangChain Python 与 Glue 目录文档加载器集成。

[AWS Glue 数据目录](https://docs.aws.amazon.com/en_en/glue/latest/dg/catalog-and-crawler.html)是一个集中的元数据存储库，允许您管理、访问和共享存储在 AWS 中的数据的元数据。它充当您数据资产的元数据存储，使各种 AWS 服务和您的应用程序能够高效地查询和连接所需的数据。

当您在 AWS Glue 中定义数据源、转换和目标时，有关这些元素的元数据会存储在数据目录中。这包括有关数据位置、模式定义、运行时指标等信息。它支持多种数据存储类型，例如 Amazon S3、Amazon RDS、Amazon Redshift 以及与 JDBC 兼容的外部数据库。它还与 Amazon Athena、Amazon Redshift Spectrum 和 Amazon EMR 直接集成，允许这些服务直接访问和查询数据。

LangChain GlueCatalogLoader 将以与 Pandas dtype 相同的格式获取给定 Glue 数据库内所有表的模式。

## 设置

* 按照[设置 AWS 账户的说明](https://docs.aws.amazon.com/athena/latest/ug/setting-up.html)操作。
* 安装 boto3 库：`pip install boto3`

## 示例

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_community.document_loaders.glue_catalog import GlueCatalogLoader
```

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
database_name = "my_database"
profile_name = "my_profile"

loader = GlueCatalogLoader(
    database=database_name,
    profile_name=profile_name,
)

schemas = loader.load()
print(schemas)
```

## 带表过滤的示例

表过滤允许您选择性地检索 Glue 数据库中特定表子集的模式信息。您可以使用 `table_filter` 参数来指定您感兴趣的确切表，而不是加载所有表的模式。

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_community.document_loaders.glue_catalog import GlueCatalogLoader
```

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
database_name = "my_database"
profile_name = "my_profile"
table_filter = ["table1", "table2", "table3"]

loader = GlueCatalogLoader(
    database=database_name, profile_name=profile_name, table_filter=table_filter
)

schemas = loader.load()
print(schemas)
```

***

<div className="source-links">
  <Callout icon="terminal-2">
    [将这些文档](/use-these-docs)通过 MCP 连接到 Claude、VSCode 等，以获取实时答案。
  </Callout>

  <Callout icon="edit">
    [在 GitHub 上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/oss/python/integrations/document_loaders/glue_catalog.mdx) 或 [提交问题](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
