PHPackages                             php-etl/sql-plugin - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. php-etl/sql-plugin

ActiveGyroscops-plugin[Database &amp; ORM](/categories/database)

php-etl/sql-plugin
==================

This plugin allows you to perform SQL queries in the ETL pipelines

v0.4.4(2y ago)03.1k1[1 PRs](https://github.com/php-etl/sql-plugin/pulls)MITPHPPHP ^8.2CI failing

Since Oct 1Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/php-etl/sql-plugin)[ Packagist](https://packagist.org/packages/php-etl/sql-plugin)[ RSS](/packages/php-etl-sql-plugin/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (15)Versions (13)Used By (0)

SQL Plugin
==========

[](#sql-plugin)

[![Mutations](https://github.com/php-etl/sql-plugin/actions/workflows/infection.yaml/badge.svg)](https://github.com/php-etl/sql-plugin/actions/workflows/infection.yaml)[![PHPUnit](https://github.com/php-etl/sql-plugin/actions/workflows/phpunit.yaml/badge.svg)](https://github.com/php-etl/sql-plugin/actions/workflows/phpunit.yaml)[![Quality](https://github.com/php-etl/sql-plugin/actions/workflows/quality.yaml/badge.svg)](https://github.com/php-etl/sql-plugin/actions/workflows/quality.yaml)[![PHPStan level 5](https://github.com/php-etl/sql-plugin/actions/workflows/phpstan-5.yaml/badge.svg)](https://github.com/php-etl/sql-plugin/actions/workflows/phpstan-5.yaml)[![PHPStan level 6](https://github.com/php-etl/sql-plugin/actions/workflows/phpstan-6.yaml/badge.svg)](https://github.com/php-etl/sql-plugin/actions/workflows/phpstan-6.yaml)[![PHPStan level 7](https://github.com/php-etl/sql-plugin/actions/workflows/phpstan-7.yaml/badge.svg)](https://github.com/php-etl/sql-plugin/actions/workflows/phpstan-7.yaml)[![PHPStan level 8](https://github.com/php-etl/sql-plugin/actions/workflows/phpstan-8.yaml/badge.svg)](https://github.com/php-etl/sql-plugin/actions/workflows/phpstan-8.yaml)[![PHP](https://camo.githubusercontent.com/a486e121969a6bbdd7e2bdf335490b10d34756349d4dee5128bdd936a59c9bc7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7068702d65746c2f73716c2d706c7567696e)](https://camo.githubusercontent.com/a486e121969a6bbdd7e2bdf335490b10d34756349d4dee5128bdd936a59c9bc7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7068702d65746c2f73716c2d706c7567696e)

What is it ?
------------

[](#what-is-it-)

The SQL plugin allows you to write your own SQL queries and use them into the Pipeline stack.

SQL, Structured Query Language, is a language for manipulating databases.

Installation
------------

[](#installation)

```
composer require php-etl/sql-plugin
```

Usage
-----

[](#usage)

### Database connection

[](#database-connection)

The SQL plugin uses the PDO extension and relies on its interface to access databases using the `dsn`, `username` and `password` parameters.

This connection must be present in any case, whether it be when defining the extractor, loader or lookup.

```
connection:
    dsn: 'mysql:host=127.0.0.1;port=3306;dbname=kiboko'
    username: username
    password: password
```

It is possible to specify options at the time of this connection using `options`. Currently, it is only possible to specify if the database connection should be persistent.

```
connection:
    # ...
    options:
      persistent: true
```

### Building an extractor

[](#building-an-extractor)

```
sql:
  extractor:
    query: 'SELECT * FROM table1'
  connection:
    dsn: 'mysql:host=127.0.0.1;port=3306;dbname=kiboko'
    username: username
    password: password
```

### Building a lookup

[](#building-a-lookup)

```
sql:
  lookup:
    query: 'SELECT * FROM table2 WHERE bar = foo'
    merge:
      map:
        - field: '[options]'
          expression: 'lookup["name"]'
  connection:
    dsn: 'mysql:host=127.0.0.1;port=3306;dbname=kiboko'
    username: username
    password: password
```

### Building a loader

[](#building-a-loader)

```
sql:
  loader:
    query: 'INSERT INTO table1 VALUES (bar, foo, barfoo)'
  connection:
    dsn: 'mysql:host=127.0.0.1;port=3306;dbname=kiboko'
    username: username
    password: password
```

Advanced Usage
--------------

[](#advanced-usage)

### Using params in your queries

[](#using-params-in-your-queries)

Thanks to the SQL plugin, it is possible to write your queries with parameters.

If you write a prepared statement using named parameters (`:param`), your parameter key in the configuration will be the name of your parameter without the `:` :

```
sql:
  loader:
    query: 'INSERT INTO table1 VALUES (:value1, :value2, :value3)'
    parameters:
      - key: value1
        value: '@=input["value1"]'
      - key: value2
        value: '@=input["value3"]'
      - key: value3
        value: '@=input["value3"]'
    # ...
```

If you are using a prepared statement using interrogative markers (`?`), your parameter key in the configuration will be its position (starting from 1) :

```
sql:
  loader:
    query: 'INSERT INTO table1 VALUES (?, ?, ?)'
    parameters:
      - key: 1
        value: '@=input["value1"]'
      - key: 2
        value: '@=input["value3"]'
      - key: 3
        value: '@=input["value3"]'
  # ...
```

### Creating before and after queries

[](#creating-before-and-after-queries)

In some cases, you may need to run queries in order to best prepare for the execution of your pipeline.

#### Before queries

[](#before-queries)

Before queries will be executed before performing the query written in the configuration. Often, these are queries that set up the database.

```
sql:
  before:
    queries:
      - 'CREATE TABLE foo (id INTEGER NOT NULL, value VARCHAR(255) NOT NULL)'
      - 'INSERT INTO foo (id, value) VALUES (1, "Lorem ipsum dolor")'
      - 'INSERT INTO foo (id, value) VALUES (2, "Sit amet consecutir")'
  # ...
```

#### After queries

[](#after-queries)

After queries will be executed after performing the query written in the configuration. Often, these are queries that clean up the database.

```
sql:
  after:
    queries:
      - 'DROP TABLE foo'
  # ...
```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance57

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~80 days

Recently: every ~20 days

Total

9

Last Release

1044d ago

PHP version history (2 changes)v0.1.x-devPHP ^8.0

v0.4.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/144109625f8029112d56f43d08120cf03a0918ea3b4fd59ab53f09b02f630b00?d=identicon)[gplanchat](/maintainers/gplanchat)

---

Top Contributors

[![sebprt](https://avatars.githubusercontent.com/u/47692802?v=4)](https://github.com/sebprt "sebprt (57 commits)")[![gplanchat](https://avatars.githubusercontent.com/u/152367?v=4)](https://github.com/gplanchat "gplanchat (49 commits)")[![JoMessina](https://avatars.githubusercontent.com/u/99172532?v=4)](https://github.com/JoMessina "JoMessina (12 commits)")[![clemzarch](https://avatars.githubusercontent.com/u/28787740?v=4)](https://github.com/clemzarch "clemzarch (10 commits)")[![programgames](https://avatars.githubusercontent.com/u/18596429?v=4)](https://github.com/programgames "programgames (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/php-etl-sql-plugin/health.svg)

```
[![Health](https://phpackages.com/badges/php-etl-sql-plugin/health.svg)](https://phpackages.com/packages/php-etl-sql-plugin)
```

###  Alternatives

[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[jolicode/castor

A lightweight and modern task runner. Automate everything. In PHP.

53541.0k3](/packages/jolicode-castor)[edyan/neuralyzer

Library and CLI for Data anonymization

53147.1k2](/packages/edyan-neuralyzer)[phpmyadmin/phpmyadmin

A web interface for MySQL and MariaDB

15378.5k4](/packages/phpmyadmin-phpmyadmin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
