2017 © Pedro Peláez
 

library db-extractor-common

Common library from Keboola Database Extractors

image

keboola/db-extractor-common

Common library from Keboola Database Extractors

  • Thursday, June 14, 2018
  • by Keboola
  • Repository
  • 5 Watchers
  • 0 Stars
  • 2,755 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 8 Open issues
  • 84 Versions
  • 5 % Grown

The README.md

# Database Extractor Common [DBC]

Common classes for creating vendor specific database extractors., (*1)

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:, (*2)

php composer.phar require db-extractor-common

composer.json, (*3)

{
  "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, (*4)

Note that as of version 7, configuration rows are supported so it is not necessary to support .yml configs or table array configurations., (*5)

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., (*6)

You will need to implement the following methods: - createConnection(array $params) - testConnection() - simpleQuery(array $table, array $columns = array()): string - getTables(?array $tables = null): array;, (*7)

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, (*8)

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, (*9)

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., (*10)

Please check the existing implementations above for help getting started., (*11)

Check username

Check username functionality compares - value of the KBC_REALUSER environment variable - and username of the database user from the configuration., (*12)

If enabled, values must be same to run the component., (*13)

If a service account is used, check is skipped. For more information see UsernameChecker class., (*14)

Example image / stack parameters, (*15)

{
  "checkUsername": {
    "enabled": true
  }
}

Service account can be defined by regular expression:, (*16)

{
  "checkUsername": {
    "enabled": true,
    "serviceAccountRegexp": "~^service_~i"
  }
}

Or user account can be defined by regular expression (inverted logic):, (*17)

{
  "checkUsername": {
    "enabled": true,
    "userAccountRegexp": "~^[0-9]{3}_"
  }
}

License

MIT licensed, see LICENSE file., (*18)

The Versions

16/06 2016
08/03 2016
07/03 2016
26/02 2016
26/02 2016
26/02 2016
26/02 2016
22/02 2016
19/02 2016
19/02 2016
19/02 2016
16/02 2016

1.0.0

1.0.0.0

  Sources   Download

The Requires

 

The Development Requires

by Miroslav Čillík

12/02 2016

0.0.4

0.0.4.0

  Sources   Download

The Requires

 

The Development Requires

by Miroslav Čillík

12/02 2016

0.0.3

0.0.3.0

  Sources   Download

The Requires

 

The Development Requires

by Miroslav Čillík

11/02 2016

0.0.2

0.0.2.0

  Sources   Download

The Requires

 

The Development Requires

by Miroslav Čillík

11/02 2016

0.0.1

0.0.1.0

  Sources   Download

The Requires

 

The Development Requires

by Miroslav Čillík