keboola/db-extractor-common
Composer 安装命令:
composer require keboola/db-extractor-common
包简介
Common library from Keboola Database Extractors
README 文档
README
Common classes for creating vendor specific database extractors.
Extractors using DBC
Development and running tests
docker compose build
docker compose run --rm tests # runs the tests
Usage
Add the library to your component's composer:
php composer.phar require db-extractor-common
composer.json
{
"require": "db-extractor-common": ^8.0
}
Usage
Create entrypoint script file run.php like this one for Mysql extractor:
https://github.com/keboola/db-extractor-mysql/blob/master/src/run.php
Note that as of version 7, configuration rows are supported so it is not necessary to support .yml configs or table array configurations.
The $config is loaded from the config.json file. You have to provide values for the data_dir and extractor_class keys.
extractor_class is the main class of derived extractor, it should extend Keboola\DbExtractor\Extractor\Extractor.
You will need to implement the following methods:
createConnection(array $params)testConnection()simpleQuery(array $table, array $columns = array()): stringgetTables(?array $tables = null): array;
Note that to support identifier sanitation, the getTables method should return a sanitizedName property for each
column. This sanitizedName should be created using Keboola\php-utils\sanitizeColumnName
If you want to implement incremental fetching, you must implement
validateIncrementalFetching(array $table, string $columnName, ?int $limit = null): void
Please see the sample in the Common class: https://github.com/keboola/db-extractor-common/blob/master/src/Keboola/DbExtractor/Extractor/Common.php#L52
The namespace of your extractor class shoud be Keboola\DbExtractor\Extractor and the name of the class should corespond to DB vendor name i.e. PgSQL, Oracle, Impala, Firebrid, DB2 and so on.
Please check the existing implementations above for help getting started.
Check username
Check username functionality compares
- value of the KBC_REALUSER environment variable
- and username of the database user from the configuration.
If enabled, values must be same to run the component.
If a service account is used, check is skipped. For more information see UsernameChecker class.
Example image / stack parameters
{
"checkUsername": {
"enabled": true
}
}
Service account can be defined by regular expression:
{
"checkUsername": {
"enabled": true,
"serviceAccountRegexp": "~^service_~i"
}
}
Or user account can be defined by regular expression (inverted logic):
{
"checkUsername": {
"enabled": true,
"userAccountRegexp": "~^[0-9]{3}_"
}
}
License
MIT licensed, see LICENSE file.
keboola/db-extractor-common 适用场景与选型建议
keboola/db-extractor-common 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13.86k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 02 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 keboola/db-extractor-common 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 keboola/db-extractor-common 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 13.86k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-02-11