> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-zh.cn/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="edit">
    [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/i18n\zh-CN\oss\python\integrations\document_loaders\glue_catalog.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
  </Callout>

  <Callout icon="terminal-2">
    [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
  </Callout>
</div>
