Skip to content

Commit 73defed

Browse files
committed
Get adapter working: pull records from mysql and pipe through built-in tapMysql plugin to convert to ndjson. Works in stream mode only so far
1 parent 6e0ac39 commit 73defed

File tree

13 files changed

+96
-9786
lines changed

13 files changed

+96
-9786
lines changed

.vscode/launch.json

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,7 @@
4545
],
4646
"console": "internalConsole",
4747
"env": {"DEBUG_LEVEL":"debug"}
48-
},
49-
{
50-
"name": "TestAdapter Debug",
51-
"type": "node",
52-
"request": "launch",
53-
"program": "${workspaceRoot}/node_modules/gulp/bin/gulp.js",
54-
"stopOnEntry": false,
55-
"args": ["--gulpfile", "./debug/gulpfile.ts", "testAdapter"],
56-
"cwd": "${workspaceRoot}",
57-
"runtimeArgs": [
58-
"--nolazy", "-r", "ts-node/register"
59-
],
60-
"console": "internalConsole",
61-
"env": {"DEBUG_LEVEL":"debug"}
62-
},
48+
},
6349
{
6450
"name": "csvParseWithoutGulp",
6551
"type": "node",

debug/gulpfile.ts

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
let gulp = require('gulp')
2-
import { src as mysqlSrc } from '../src/plugin'
2+
import * as tapMysql from '../src/plugin'
33

44
import * as loglevel from 'loglevel'
55
const log = loglevel.getLogger('gulpfile')
@@ -24,32 +24,6 @@ function switchToBuffer(callback: any) {
2424
callback();
2525
}
2626

27-
function runTapCsv(callback: any) {
28-
log.info('gulp task starting for ' + PLUGIN_NAME)
29-
30-
return gulp.src('../testdata/*.csv',{buffer:gulpBufferMode})
31-
.pipe(errorHandler(function(err:any) {
32-
log.error('Error: ' + err)
33-
callback(err)
34-
}))
35-
.on('data', function (file:Vinyl) {
36-
log.info('Starting processing on ' + file.basename)
37-
})
38-
// .pipe(tapCsv({raw:true/*, info:true */}))
39-
.pipe(rename({
40-
extname: ".ndjson",
41-
}))
42-
.pipe(gulp.dest('../testdata/processed'))
43-
.on('data', function (file:Vinyl) {
44-
log.info('Finished processing on ' + file.basename)
45-
})
46-
.on('end', function () {
47-
log.info('gulp task complete')
48-
callback()
49-
})
50-
51-
}
52-
5327
export function csvParseWithoutGulp(callback: any) {
5428

5529
const parse = require('csv-parse')
@@ -65,13 +39,30 @@ export function csvParseWithoutGulp(callback: any) {
6539

6640

6741

68-
export function testAdapter(callback: any) {
42+
function testAdapter(callback: any) {
6943
log.info('gulp task starting for ' + PLUGIN_NAME)
7044

7145
try {
7246

73-
74-
return mysqlSrc('../testdata/cars.csv',{buffer:gulpBufferMode})
47+
// contains secure info; store in parent folder of this project, outside of repo
48+
let configObj = require('../../mysql-settings.json')
49+
50+
/*
51+
let configObj =
52+
// mysql-settings.json should look like this:
53+
{
54+
"sql": "SELECT * FROM customers LIMIT 2;",
55+
"connection": {
56+
"host" : "example.org",
57+
"user" : "bob",
58+
"password" : "secret",
59+
"database" : "schemaName"
60+
}
61+
}
62+
63+
*/
64+
65+
return tapMysql.src('mysqlResults',configObj)
7566
.pipe(errorHandler(function(err:any) {
7667
log.error('Error: ' + err)
7768
callback(err)
@@ -99,5 +90,5 @@ export function testAdapter(callback: any) {
9990

10091
}
10192

102-
exports.default = gulp.series(runTapCsv)
103-
exports.runTapCsvBuffer = gulp.series(switchToBuffer, runTapCsv)
93+
exports.default = gulp.series(testAdapter)
94+
exports.runTapCsvBuffer = gulp.series(switchToBuffer, testAdapter)

package-lock.json

Lines changed: 37 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"from2": "^2.3.0",
2525
"gulp-error-handle": "^1.0.1",
2626
"loglevel": "^1.6.1",
27+
"mysql": "^2.17.1",
2728
"pkginfo": "^0.4.1",
2829
"plugin-error": "^1.0.1",
2930
"through2": "^3.0.1",
@@ -34,6 +35,7 @@
3435
"@types/gulp-rename": "0.0.33",
3536
"@types/jest": "^23.3.14",
3637
"@types/loglevel": "^1.5.4",
38+
"@types/mysql": "^2.15.6",
3739
"@types/node": "^10.14.6",
3840
"@types/vinyl": "^2.0.3",
3941
"@types/vinyl-paths": "0.0.31",

src/aws/dev-handler.ts

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)