Skip to content

Commit 9f38959

Browse files
committed
Add MySqlProcessor and MySqlDestination.
1 parent 081b64a commit 9f38959

File tree

11 files changed

+552
-941
lines changed

11 files changed

+552
-941
lines changed

README.md

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ Each processor in `bellboy` is a class which has a single responsibility of proc
307307
- [JsonProcessor](#json-processor) processes **JSON** file data from the file system.
308308
- [DelimitedProcessor](#delimited-processor) processes files with **delimited data** from the file system.
309309
- [PostgresProcessor](#postgres-processor) processes data received from a **PostgreSQL** SELECT.
310+
- [MySqlProcessor](#mysql-processor) processes data received from a **MySQL** SELECT.
310311
- [MssqlProcessor](#mssql-processor) processes data received from a **MSSQL** SELECT.
311312
- [DynamicProcessor](#dynamic-processor) processes **dynamically generated** data.
312313
- [TailProcessor](#tail-processor) processes **new lines** added to the file.
@@ -526,6 +527,22 @@ Processes a PostgreSQL `SELECT` query row by row.
526527
- **database**
527528
- **schema**
528529

530+
### MySqlProcessor <div id='mysql-processor'/>
531+
532+
Processes a MySQL `SELECT` query row by row.
533+
534+
#### Options
535+
536+
- [Processor options](#processor-options)
537+
- **query** `string` `required`\
538+
Query to execute.
539+
- **connection** `object` `required`
540+
- **user**
541+
- **password**
542+
- **host**
543+
- **port**
544+
- **database**
545+
529546
### MssqlProcessor <div id='mssql-processor'/>
530547

531548
Processes a MSSQL `SELECT` query row by row.
@@ -542,22 +559,25 @@ Processes a MSSQL `SELECT` query row by row.
542559
- **port**
543560
- **database**
544561
- **driver**\
545-
Optional [mssql][mssql-url] TDS driver; defaults to the pure JavaScript [Tedious][tedious-url] driver.
562+
Optional [mssql][mssql-url] TDS driver; defaults to the pure JavaScript [Tedious][tedious-url] driver.
546563

547564
#### Usage
548565

549566
Here is an example of how to configure `MssqlProcessor` with a native TDS driver instead of the default pure JavasScript Tedious driver.
550567

551568
```javascript
552-
const nativeDriver: ITdsDriver = await import('mssql/msnodesqlV8');
569+
const nativeDriver: ITdsDriver = await import("mssql/msnodesqlV8");
553570
const connection: IMssqlDbConnection = {
554-
user: 'user',
555-
password: 'password',
556-
server: 'server',
557-
database: 'database',
558-
driver: nativeDriver
571+
user: "user",
572+
password: "password",
573+
server: "server",
574+
database: "database",
575+
driver: nativeDriver,
559576
};
560-
const source = new MssqlProcessor({ connection, query: 'select * from orders' });
577+
const source = new MssqlProcessor({
578+
connection,
579+
query: "select * from orders",
580+
});
561581
```
562582

563583
In previous versions of `bellboy`, `connection.driver` was a `string` parameter.
@@ -592,6 +612,7 @@ Every [job](#job) can have as many destinations (outputs) as needed. For example
592612
- [StdoutDestination](#stdout-destination) logs data to **console**.
593613
- [HttpDestination](#http-destination) executes **HTTP** request calls.
594614
- [PostgresDestination](#postgres-destination) inserts/upserts data to **PostgreSQL** database.
615+
- [MySqlDestination](#mysql-destination) inserts/upserts data to **MySQL** database.
595616
- [MssqlDestination](#mssql-destination) inserts data to **MSSQL** database.
596617

597618
### Options <div id='destination-options'/>
@@ -658,6 +679,23 @@ Inserts data to PostgreSQL.
658679
- **database**
659680
- **schema**
660681

682+
### MySqlDestination <div id='mysql-destination'/>
683+
684+
[Usage examples](tests/mysql-destination.spec.ts)
685+
686+
Inserts data to MySQL.
687+
688+
#### Options
689+
690+
- [General destination options](#destination-options)
691+
- **table** `string` `required`\
692+
Table name.
693+
- **connection** `object` `required`
694+
- **user**
695+
- **password**
696+
- **host**
697+
- **database**
698+
661699
### MssqlDestination <div id='mssql-destination'/>
662700

663701
[Usage examples](tests/mssql-destination.spec.ts)
@@ -675,22 +713,26 @@ Inserts data to MSSQL.
675713
- **server**
676714
- **database**
677715
- **driver** \
678-
Optional [mssql][mssql-url] TDS driver; defaults to the pure JavaScript [Tedious][tedious-url] driver.
716+
Optional [mssql][mssql-url] TDS driver; defaults to the pure JavaScript [Tedious][tedious-url] driver.
679717

680718
#### Usage
681719

682720
Here is an example of how to configure `MssqlDestination` with a native TDS driver instead of the default pure JavasScript Tedious driver.
683721

684722
```javascript
685-
const nativeDriver: ITdsDriver = await import('mssql/msnodesqlV8');
723+
const nativeDriver: ITdsDriver = await import("mssql/msnodesqlV8");
686724
const connection: IMssqlDbConnection = {
687-
user: 'user',
688-
password: 'password',
689-
server: 'server',
690-
database: 'database',
691-
driver: nativeDriver
725+
user: "user",
726+
password: "password",
727+
server: "server",
728+
database: "database",
729+
driver: nativeDriver,
692730
};
693-
const sink = new MssqlDestination({ connection, table: 'orders', batchSize: 1000 });
731+
const sink = new MssqlDestination({
732+
connection,
733+
table: "orders",
734+
batchSize: 1000,
735+
});
694736
```
695737

696738
[More usage examples](tests/mssql-destination.spec.ts)

docker-compose.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ services:
66
depends_on:
77
- postgres
88
- mssql
9-
command: ./wait-for-it.sh postgres:5432 -- ./wait-for-it.sh mssql:1433 -- npm test
9+
- mysql
10+
command: ./wait-for-it.sh postgres:5432 -- ./wait-for-it.sh mssql:1433 -- ./wait-for-it.sh mysql:3306 -- npm test
1011
environment:
1112
NODE_ENV: development
1213
volumes:
@@ -17,6 +18,12 @@ services:
1718
environment:
1819
POSTGRES_PASSWORD: password
1920

21+
mysql:
22+
image: mysql
23+
environment:
24+
MYSQL_ROOT_PASSWORD: password
25+
MYSQL_DATABASE: test
26+
2027
mssql:
2128
image: mcr.microsoft.com/azure-sql-edge
2229
environment:

0 commit comments

Comments
 (0)