keboola / db-extractor-adapter
Set of connection adapters for DB extractors.
1.15.1
2024-12-03 11:52 UTC
Requires
- php: >=8.2
- ext-iconv: *
- keboola/common-exceptions: ^1.0
- keboola/csv: ^3.2
- keboola/db-extractor-config: ^1.15
- keboola/db-extractor-table-format: ^3.7
- keboola/retry: ^0.5
- keboola/ssh-tunnel: ^2.2
- psr/log: ^1.1
Requires (Dev)
- ext-json: *
- ihsw/toxiproxy-php-client: ^2.0
- keboola/coding-standard: >=9.0
- keboola/php-temp: ^2.0
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.1
Suggests
- ext-odbc: Needed to support ODBC connection
- ext-pdo: Needed to support PDO connection
This package is auto-updated.
Last update: 2024-12-03 11:53:07 UTC
README
This library contains a common interface for connecting to and data extracting from, various sources:
- It is intended for use with db-extractor-common.
- It supports PDO and ODBC connections for now.
- The interfaces defined in this library can be easily used to support other methods, e.g. cli BCP tool.
Main Classes
- Interface
DbConnection
is an abstraction that represents a connection to the database.- Abstract class
BaseDbConnection
contains common code and retry mechanisms. - Class
PdoDbConnection
implements connection using PDO extension. - Class
OdbcDbConnection
implements connection using ODBC extension.
- Abstract class
- Interface
QueryResult
is an abstraction that represents query result - rows returned from database.- Class
PdoQueryResult
represents result from PDO connection. - Class
OdbcQueryResult
represents result from ODBC connection.
- Class
- Interface
ExportAdapter
is an abstraction which defines how the data is to be extracted.- Based on
ExportConfig
,ExportResult
is generated. The rows are written to the specified CSV file. - By implementing this interface, it is possible to add support for CLI tools for export.
- Abstract class
BaseExportAdapter
contains common code. - Class
PdoExportAdapter
implements export for PDO connection. - Class
OdbcExportAdapter
implements export for ODBC connection. - Class
FallbackExportAdapter
allows you to use multiple adapters. If one fails, then fallback adapter is used.
- Based on
- Interface
QueryFactory
used to generate SQL query fromExportConfig
. It is used if query is not set in the config.- Class
DefaultQueryFactory
is base implementation for MySQL/MariaDb compatible SQL dialects.
- Class
- Class
QueryResultCsvWriter
used to write rows from theQueryResult
to the specified CSV file.
Development
Clone this repository and init the workspace with following command:
git clone https://github.com/keboola/db-extractor-adapter
cd db-extractor-adapter
docker compose build
docker compose run --rm dev composer install --no-scripts
Run the test suite using this command:
docker compose run --rm dev composer tests
License
MIT licensed, see LICENSE file.