Common library from Keboola Database Extractors

14.0.4 2020-08-26 15:09 UTC


Build Status

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


Add the library to your component's composer:

php composer.phar require db-extractor-common


  "require": "db-extractor-common": ^8.0


Create entrypoint script file run.php like this one for Mysql extractor:

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:

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.