keboola / db-extractor-common
Common library from Keboola Database Extractors
Requires
- php: >=8.2
- ext-json: *
- ext-pdo: *
- keboola/common-exceptions: ^1.1
- keboola/csv: ^3.2
- keboola/db-extractor-adapter: ^1.15.1
- keboola/db-extractor-config: ^1.15
- keboola/db-extractor-ssh-tunnel: ^1.3.0
- keboola/db-extractor-table-format: ^3.8
- keboola/php-component: ^10.0
- keboola/php-datatypes: ^7.2
- keboola/php-utils: ^2.3||^3.0||^4.0
- keboola/retry: ^0.5
- monolog/monolog: ^2.0
- nette/utils: ^3.0
- phpunit/phpunit: ^9.1
- pimple/pimple: ^3.3
- psr/log: ^1.1
Requires (Dev)
- cweagans/composer-patches: ^1.7
- ihsw/toxiproxy-php-client: ^2.0
- keboola/coding-standard: >=13.0
- keboola/php-temp: ^2.0
- php-parallel-lint/php-parallel-lint: ^1.2
- phpstan/phpstan: ^1.10
- symfony/debug: ^4.3
- symfony/finder: ^6.3
- symplify/vendor-patches: ^11.2
- dev-master
- 17.2.1
- 17.2.0
- 17.1.2
- 17.1.1
- 17.1.0
- 17.0.11
- 17.0.10
- 17.0.9
- 17.0.8
- 17.0.7
- 17.0.6
- 17.0.5
- 17.0.4
- 17.0.3
- 17.0.2
- 17.0.1
- 17.0.0
- 16.2.2
- 16.2.1
- 16.2.0
- 16.1.0
- 16.0.1
- 16.0.0
- 15.0.1
- 15.0.0
- 14.6.0
- 14.5.3
- 14.5.2
- 14.5.1
- 14.5.0
- 14.4.0
- 14.3.0
- 14.2.3
- 14.2.2
- 14.2.1
- 14.2.0
- 14.1.0
- 14.0.4
- 14.0.3
- 14.0.2
- 14.0.1
- 14.0.0
- 13.3.0
- 13.2.4
- 13.2.3
- 13.2.2
- 13.2.1
- 13.2.0
- 13.1.0
- 13.0.0
- 12.2.0
- 12.1.2
- 12.1.1
- 12.1.0
- 12.0.1
- 12.0.0
- 11.0.0
- 10.0.1
- 10.0.0
- 9.4.1
- 9.4.0
- 9.3.2
- 9.3.1
- 9.3.0
- 9.2.1
- 9.2.0
- 9.1.11
- 9.1.10
- 9.1.9
- 9.1.8
- 9.1.7
- 9.1.6
- 9.1.5
- 9.1.4
- 9.1.3
- 9.1.2
- 9.1.1
- 9.1.0
- 9.0.0
- 8.1.0
- 8.0.0
- 7.0.0
- 6.2.0
- 6.1.0
- 6.0.0
- 5.3.2
- 5.3.1
- 5.3.0
- 5.2.3
- 5.2.2
- 5.2.1
- 5.2.0
- 5.1.0
- 5.0.2
- 5.0.1
- 5.0.0
- 4.1.1
- 4.1.0
- 4.0.6
- 4.0.5
- 4.0.4
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.3
- 3.1.1
- 3.1.0
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.4.0
- 1.3.0
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.1
- 1.1.0
- 1.0.0
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
- dev-roman-fix-adapter-min-version
- dev-ondra-setup-logger
- dev-webrouse-254-db-adapter
- dev-piv-ignore-extra-action-keys
- dev-tf-testing-rf
- dev-david-value-objects
- dev-david-v10
- dev-ujovlado-notifications
- dev-piv-retry-connection
- dev-piv-tunnel-c
- dev-backup-david-value-objects-2019-01-23
- dev-backup-v10-before-rebase-2019-01-23
- dev-piv-update-php-datatypes
- dev-php55
This package is auto-updated.
Last update: 2024-12-06 13:58:44 UTC
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()): string
getTables(?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.