

# 从 QuickBooks 实体读取内容
<a name="quickbooks-reading-from-entities"></a>

**先决条件**

要从中读取内容的 QuickBooks 对象。

**源支持的实体**：


| 实体 | 可以筛选 | 支持限制 | 支持排序依据 | 支持 Select \$1 | 支持分区 | 
| --- | --- | --- | --- | --- | --- | 
| Account | 支持 | 是 | 是 | 是 | 是 | 
| 账单 | 支持 | 是 | 是 | 是 | 是 | 
| 公司信息 | 否 | 否 | 否 | 是 | 否 | 
| Customer | 支持 | 是 | 是 | 是 | 是 | 
| 员工 | 支持 | 是 | 是 | 是 | 是 | 
| Estimate | 支持 | 是 | 是 | 是 | 是 | 
| 发票 | 支持 | 是 | 是 | 是 | 是 | 
| Item | 支持 | 是 | 是 | 是 | 是 | 
| Payment | 支持 | 是 | 是 | 是 | 是 | 
| Preferences（首选项） | 否 | 否 | 否 | 是 | 否 | 
| 盈亏 | 是 | 否 | 否 | 是 | 否 | 
| 税务局 | 支持 | 是 | 是 | 是 | 是 | 
| 供应商 | 支持 | 是 | 是 | 是 | 是 | 

**示例：**

```
QuickBooks_read = glueContext.create_dynamic_frame.from_options(
    connection_type="quickbooks",
    connection_options={
        "connectionName": "connectionName",
        "ENTITY_NAME": "Account",
        "API_VERSION": "v3"
    }
```

**QuickBooks 实体和字段详细信息**：

有关实体和字段详细信息的更多信息，请参阅：
+ [Account](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/account)
+ [Bill](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/bill)
+ [CompanyInfo](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/companyinfo)
+ [Customer](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/customer)
+ [Employee](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/employee)
+ [Estimate](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/estimate)
+ [Invoice](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/invoice)
+ [Item](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/item)
+ [Payment](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/payment)
+ [Preferences](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/preferences)
+ [ProfitAndLoss](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/profitandloss)
+ [TaxAgency](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/taxagency)
+ [Vendor](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/vendor)

## 对查询进行分区
<a name="quickbooks-reading-partitioning-queries"></a>

**基于字段的分区**：

在 QuickBooks 中，“整数”和“日期时间”数据类型字段支持基于字段的分区。

如果您想在 Spark 中利用并发，可以提供其他 Spark 选项：`PARTITION_FIELD`、`LOWER_BOUND`、`UPPER_BOUND` 和 `NUM_PARTITIONS`。使用这些参数，原始查询将被拆分为 `NUM_PARTITIONS` 个子查询，这些子查询可以由 Spark 任务同时执行。
+ `PARTITION_FIELD`：用于对查询进行分区的字段的名称。
+ `LOWER_BOUND`：所选分区字段的**包含**下限值。

  对于“日期时间”字段，我们接受 Spark SQL 查询中使用的 Spark 时间戳格式。

  有效值示例：

  ```
  "2024-05-07T02:03:00.00Z"
  ```
+ `UPPER_BOUND`：所选分区字段的**排除**上限值。
+ `NUM_PARTITIONS`：分区的数量。

示例：

```
QuickBooks_read = glueContext.create_dynamic_frame.from_options(
    connection_type="quickbooks",
    connection_options={
        "connectionName": "connectionName",
        "REALMID": "12345678690123456789",
        "ENTITY_NAME": "Account",
        "API_VERSION": "v3",
        "PARTITION_FIELD": "MetaData_CreateTime"
        "LOWER_BOUND": "2023-09-07T02:03:00.000Z"
        "UPPER_BOUND": "2024-05-07T02:03:00.000Z"
        "NUM_PARTITIONS": "10"
    }
```

**基于记录的分区**：

原始查询将被拆分为 `NUM_PARTITIONS` 个子查询，这些子查询可以由 Spark 任务同时执行：
+ `NUM_PARTITIONS`：分区的数量。

示例：

```
QuickBooks_read = glueContext.create_dynamic_frame.from_options(
    connection_type="quickbooks",
    connection_options={
        "connectionName": "connectionName",
        "REALMID": "1234567890123456789",
        "ENTITY_NAME": "Bill",
        "API_VERSION": "v3",
        "NUM_PARTITIONS": "10"
    }
```