Skip to main content

AWS Redshift to MySQL

Read rows from AWS Redshift table using them to insert rows into MySQL table

Clone to YepCode
Share

Read rows from AWS Redshift table

Used integrations:
class AwsRedshiftSourceSelect {    async init() { // initialize a AWS Redshift client        this.awsRedshift = yepcode.integration.awsRedshift("your-aws-redshift-credential-name"); // Prepare the command to execute, customize the params and the SQL query        const executeStatementCommand = new ExecuteStatementCommand({            ClusterIdentifier: "your-cluster-identifier",            Database: "your-database-name",            DbUser: "your-database-user",            Sql: "SELECT * FROM your-table-name;"        });        const {            Id        } = await this.awsRedshift.send(executeStatementCommand);        this.statementId = Id;        await this._awaitStatementToFinish();    }    async fetch(publish, done) {        let nextToken; // if result is returned paginated, iterate to publish entire statement result        do {            const result = await this.awsRedshift.send(new GetStatementResultCommand({                Id: this.statementId,                NextToken: nextToken            }));            nextToken = result.NextToken;            for (const record of result.Records) { // Each record come as a list of record cells                // An small example: [ { stringValue: 'the-string-value' }, { longValue: 1234 } ]                // You can map your record to a JSON object                await publish(record);            }        } while (nextToken);        done();    }    async close() {}    _awaitStatementToFinish() {        return new Promise((resolve, reject) => {            const describeStatementCommand = new DescribeStatementCommand({                Id: this.statementId            }); // configure interval to check statement status            const intervalId = setInterval(async () => {                const result = await this.awsRedshift.send(describeStatementCommand);                if (result.Status === "FINISHED") {                    clearInterval(intervalId);                    resolve();                    return;                }                if (result.Status === "FAILED" || result.Status === "ABORTED") {                    clearInterval(intervalId);                    reject();                    return;                }            }, 1000);        });    }}

Insert rows into MySQL table

Used integrations:
class MysqlTargetInsert {    async init() { // initialize an mysql client        this.mysql = yepcode.integration.mysql("your-mysql-credential-name");    }    async consume(item) { // Map your item to row        return await this.mysql.promise().query(`INSERT INTO your_table_name SET ?`, {            id: item.id,            name: item.name        });    }    async close() {        await this.mysql.end();    }}

Find related recipes

  • AWS Redshift
  • MySQL

FAQs

These recipes are a good starting point for you to build your own YepCode processes and solve your integration and automation problems.

YepCode is a SaaS platform that allows to create, execute and monitor integrations and automations using source code in a serverless environment.

We like to call it the Zapier for developers, since we bring all the agility and benefits of NoCode tools (avoid server provisioning, environment configuration, deployments,...), but with all the power of being able to use a programming language like JavaScript with a NodeJS engine.

You only have to fill the sign up form and your account will be created with our FREE plan (no credit card required).

YepCode has been created with a clear enterprise approach (multi-tenant environment, team management, high security and auditing standards, IdP integrations, on-premise options,...) so we can be the Swiss army knife of any team of engineering, especially those that need to extract or send information to external systems, and where a certain dynamism or adaptation to change is necessary in that process.

Sure! You just need to do some configuration to allow YepCode servers to connect to that service. Check our docs page to get more information.