Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/mysql/actions/create-row/create-row.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
name: "Create Row",
description: "Adds a new row. [See the docs here](https://dev.mysql.com/doc/refman/8.0/en/insert.html)",
type: "action",
version: "1.0.0",
version: "1.0.1",
props: {
mysql,
table: {
Expand Down
2 changes: 1 addition & 1 deletion components/mysql/actions/delete-row/delete-row.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "Delete Row",
description: "Delete an existing row. [See the docs here](https://dev.mysql.com/doc/refman/8.0/en/delete.html)",
type: "action",
version: "1.0.0",
version: "1.0.1",
props: {
mysql,
table: {
Expand Down
2 changes: 1 addition & 1 deletion components/mysql/actions/execute-query/execute-query.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "Execute Query",
description: "Find row(s) via a custom query. [See the docs here](https://dev.mysql.com/doc/refman/8.0/en/select.html)",
type: "action",
version: "1.0.0",
version: "1.0.1",
props: {
mysql,
table: {
Expand Down
22 changes: 22 additions & 0 deletions components/mysql/actions/execute-raw-query/execute-raw-query.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import mysql from "../../mysql.app.mjs";

export default {
key: "mysql-execute-raw-query",
name: "Execute Raw Query",
description: "Find row(s) via a custom raw query. [See the documentation](https://dev.mysql.com/doc/refman/8.0/en/select.html)",
type: "action",
version: "0.0.1",
props: {
mysql,
sql: {
type: "string",
label: "Query",
description: "The SQL query to execute",
},
},
run() {
return this.mysql.executeQuery({
sql: this.sql,
});
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "Execute Stored Procedure",
description: "Execute Stored Procedure. [See the docs here](https://dev.mysql.com/doc/refman/8.0/en/stored-programs-defining.html)",
type: "action",
version: "1.0.0",
version: "1.0.1",
props: {
mysql,
storedProcedure: {
Expand Down
2 changes: 1 addition & 1 deletion components/mysql/actions/find-row/find-row.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "Find Row",
description: "Finds a row in a table via a lookup column. [See the docs here](https://dev.mysql.com/doc/refman/8.0/en/select.html)",
type: "action",
version: "1.0.0",
version: "1.0.1",
props: {
mysql,
table: {
Expand Down
2 changes: 1 addition & 1 deletion components/mysql/actions/update-row/update-row.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
name: "Update Row",
description: "Updates an existing row. [See the docs here](https://dev.mysql.com/doc/refman/8.0/en/update.html)",
type: "action",
version: "1.0.0",
version: "1.0.1",
props: {
mysql,
table: {
Expand Down
72 changes: 54 additions & 18 deletions components/mysql/mysql.app.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import mysqlClient from "mysql2/promise";
import { sqlProxy } from "@pipedream/platform";

export default {
type: "app",
Expand Down Expand Up @@ -95,7 +96,15 @@ export default {
},
},
methods: {
getConfig() {
...sqlProxy.methods,
/**
* A helper method to get the configuration object that's directly fed to
* the MySQL client constructor. Used by other features (like the SQL proxy)
* to initialize their clients in an identical way.
*
* @returns {object} - Configuration object for the MySQL client
*/
getClientConfiguration() {
const {
host,
port,
Expand All @@ -105,6 +114,7 @@ export default {
ca,
key,
cert,
reject_unauthorized: rejectUnauthorized = true,
} = this.$auth;

return {
Expand All @@ -113,24 +123,44 @@ export default {
user: username,
password,
database,
...(ca && cert && key && {
ssl: {
rejectUnauthorized: true,
ca,
cert,
key,
},
}),
ssl: {
rejectUnauthorized,
ca,
cert,
key,
},
};
},
async closeConnection(connection) {
await connection.end();
return new Promise((resolve) => {
connection.connection.stream.on("close", resolve);
});
/**
* Adapts the arguments to `executeQuery` so that they can be consumed by
* the SQL proxy (when applicable). Note that this method is not intended to
* be used by the component directly.
* @param {object} preparedStatement The prepared statement to be sent to the DB.
* @param {string} preparedStatement.sql The prepared SQL query to be executed.
* @param {string[]} preparedStatement.values The values to replace in the SQL query.
* @returns {object} - The adapted query and parameters.
*/
proxyAdapter(preparedStatement = {}) {
const {
sql: query = "",
values: params = [],
} = preparedStatement;
return {
query,
params,
};
},
/**
* Executes a query against the MySQL database. This method takes care of
* connecting to the database, executing the query, and closing the
* connection.
* @param {object} preparedStatement - The prepared statement to be sent to the DB.
* @param {string} preparedStatement.sql - The prepared SQL query to be executed.
* @param {string[]} preparedStatement.values - The values to replace in the SQL query.
* @returns {object[]} - The rows returned by the DB as a result of the query.
*/
async executeQuery(preparedStatement = {}) {
const config = this.getConfig();
const config = this.getClientConfiguration();
let connection;
try {
connection = await mysqlClient.createConnection(config);
Expand All @@ -149,6 +179,12 @@ export default {
}
}
},
async closeConnection(connection) {
await connection.end();
return new Promise((resolve) => {
connection.connection.stream.on("close", resolve);
});
},
async listStoredProcedures(args = {}) {
const procedures = await this.executeQuery({
sql: "SHOW PROCEDURE STATUS",
Expand Down Expand Up @@ -176,7 +212,7 @@ export default {
} = {}) {
return this.executeQuery({
sql: `
SELECT * FROM INFORMATION_SCHEMA.TABLES
SELECT * FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
AND CREATE_TIME > ?
ORDER BY CREATE_TIME DESC
Expand All @@ -192,7 +228,7 @@ export default {
} = {}) {
return this.executeQuery({
sql: `
SELECT * FROM INFORMATION_SCHEMA.TABLES
SELECT * FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
ORDER BY CREATE_TIME DESC
LIMIT ${maxCount}
Expand Down Expand Up @@ -236,7 +272,7 @@ export default {
return this.executeQuery({
sql: `
SELECT * FROM \`${table}\`
WHERE \`${column}\` > ?
WHERE \`${column}\` > ?
ORDER BY \`${column}\` DESC
`,
values: [
Expand Down
6 changes: 3 additions & 3 deletions components/mysql/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@pipedream/mysql",
"version": "1.0.0",
"description": "Pipedream Mysql Components",
"version": "1.0.1",
"description": "Pipedream MySQL Components",
"main": "mysql.app.mjs",
"keywords": [
"pipedream",
Expand All @@ -12,7 +12,7 @@
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^1.2.0",
"@pipedream/platform": "^1.6.2",
"mysql2": "^3.9.2",
"mysql2-promise": "^0.1.4",
"uuid": "^8.3.2"
Expand Down
2 changes: 1 addition & 1 deletion components/mysql/sources/new-column/new-column.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
name: "New Column",
description: "Emit new event when you add a new column to a table. [See the docs here](https://dev.mysql.com/doc/refman/8.0/en/show-columns.html)",
type: "source",
version: "1.0.0",
version: "1.0.1",
dedupe: "unique",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
name: "New or Updated Row",
description: "Emit new event when you add or modify a new row in a table. [See the docs here](https://dev.mysql.com/doc/refman/8.0/en/select.html)",
type: "source",
version: "1.0.0",
version: "1.0.1",
dedupe: "unique",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
key: "mysql-new-row-custom-query",
name: "New Row (Custom Query)",
description: "Emit new event when new rows are returned from a custom query. [See the docs here](https://dev.mysql.com/doc/refman/8.0/en/select.html)",
version: "1.0.0",
version: "1.0.1",
type: "source",
dedupe: "unique",
props: {
Expand Down
2 changes: 1 addition & 1 deletion components/mysql/sources/new-row/new-row.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
name: "New Row",
description: "Emit new event when you add a new row to a table. [See the docs here](https://dev.mysql.com/doc/refman/8.0/en/select.html)",
type: "source",
version: "1.0.0",
version: "1.0.1",
dedupe: "unique",
props: {
...common.props,
Expand Down
2 changes: 1 addition & 1 deletion components/mysql/sources/new-table/new-table.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
name: "New Table",
description: "Emit new event when a new table is added to a database. [See the docs here](https://dev.mysql.com/doc/refman/8.0/en/select.html)",
type: "source",
version: "1.0.0",
version: "1.0.1",
dedupe: "unique",
props: {
...common.props,
Expand Down
11 changes: 0 additions & 11 deletions components/mysql_test/mysql_test.app.mjs

This file was deleted.

15 changes: 0 additions & 15 deletions components/mysql_test/package.json

This file was deleted.

15 changes: 6 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.