How to use vogievetsky-mysql2 - 3 common examples

To help you get started, we’ve selected a few vogievetsky-mysql2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github implydata / plyql / test / mysql-gateway-node-client.mocha.js View on Github external
child.stdout.on('data', (data) => {
      data = data.toString();
      if (data.indexOf(`port: ${TEST_PORT}`) !== -1) {
        connection = mysql.createConnection({
          port: 13307,
          database: 'plywood',
          user: 'root',
          password: ''
        });

        connection.on('error', (err) => {
          // nothing to do here, have a noop function to prevent the error form being thrown
        });

        done();
      }
    });
github implydata / plyql / src / mysql-gateway.ts View on Github external
export function fallbackMySQLFactory(connectionUri: string) {
  let remote = mysql.createConnection(connectionUri);
  remote.query('select 1 as one', (err, res) => {
    if (err) {
      console.log('Connection to real MySQL fail');
      process.exit(1);
    } else {
      console.log('Connection to real MySQL success');
    }
  });

  return function (sql: string, conn: any) {
    remote.query(sql, function(err: Error, rows: any[], columns: any[]) {
      // overloaded args, either (err, result :object)
      // or (err, rows :array, columns :array)

      if (err) {
        console.log('GOT ERROR', (err as any).code, err.message);
github implydata / plyql / src / mysql-gateway.ts View on Github external
export function createMySQLGateway(port: number, queryProcessor: MySQLQueryProcessor) {
  let server = mysql.createServer();
  server.listen(port);
  console.log(`MySQL Gateway listening on port: ${port}`);
  console.log(`you can connect to it using \`mysql --host=127.0.0.1 --port=${port}\``);

  let connectionId = 0;
  server.on('connection', function(conn) {
    connectionId++;
    console.log(`New connection ${connectionId}`);

    conn.serverHandshake({
      protocolVersion: 10,
      serverVersion: '5.7.11',
      connectionId,
      statusFlags: 2,
      characterSet: CHARSETS['UTF8MB4_UNICODE_CI'],
      capabilityFlags

vogievetsky-mysql2

fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS

MIT
Latest version published 9 years ago

Package Health Score

69 / 100
Full package analysis