How to use sql-client - 8 common examples

To help you get started, we’ve selected a few sql-client 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 ioBroker / ioBroker.sql / lib / mssql-client.js View on Github external
(function() {
    let ConnectionFactory = require('sql-client/lib/connection-factory').ConnectionFactory;
    let SQLClient = require('sql-client/lib/sql-client').SQLClient;
    let SQLClientPool = require('sql-client/lib/sql-client-pool').SQLClientPool;
    let mssql = require('mssql');

    let bind = function (fn, me){ return function (){ return fn.apply(me, arguments); }; };
    let extend = function (child, parent) { for (const key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
    let hasProp = {}.hasOwnProperty;
    let slice = [].slice;

    let MSSQLConnectionFactory = (function(superClass) {
        extend(MSSQLConnectionFactory, superClass);

        function MSSQLConnectionFactory() {
            this.execute = bind(this.execute, this);
            this.open_connection = bind(this.open_connection, this);
            return MSSQLConnectionFactory.__super__.constructor.apply(this, arguments);
github ioBroker / ioBroker.sql / lib / postgresql-client.js View on Github external
(function() {
  var ConnectionFactory,  PostgreSQLClient, PostgreSQLClient2, PostgreSQLClientPool, PostgreSQLClientPool2, PostgreSQLConnectionFactory, PostgreSQLConnectionFactory2, SQLClient, SQLClientPool, pg,
    bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty,
    slice = [].slice;

  SQLClient = require('sql-client/lib/sql-client').SQLClient;

  SQLClientPool = require('sql-client/lib/sql-client-pool').SQLClientPool;

  ConnectionFactory = require('sql-client/lib/connection-factory').ConnectionFactory;

  pg = require('pg');
    try {
        if ((pg != null ? pg["native"] : void 0) != null) {
            pg = pg["native"];
        }
    } catch(err) {

    }


  PostgreSQLConnectionFactory = (function(superClass) {
    extend(PostgreSQLConnectionFactory, superClass);

    function PostgreSQLConnectionFactory() {
      this.pre_process_sql = bind(this.pre_process_sql, this);
github ioBroker / ioBroker.sql / lib / postgresql-client.js View on Github external
(function() {
  var ConnectionFactory,  PostgreSQLClient, PostgreSQLClient2, PostgreSQLClientPool, PostgreSQLClientPool2, PostgreSQLConnectionFactory, PostgreSQLConnectionFactory2, SQLClient, SQLClientPool, pg,
    bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty,
    slice = [].slice;

  SQLClient = require('sql-client/lib/sql-client').SQLClient;

  SQLClientPool = require('sql-client/lib/sql-client-pool').SQLClientPool;

  ConnectionFactory = require('sql-client/lib/connection-factory').ConnectionFactory;

  pg = require('pg');
    try {
        if ((pg != null ? pg["native"] : void 0) != null) {
            pg = pg["native"];
        }
    } catch(err) {

    }


  PostgreSQLConnectionFactory = (function(superClass) {
    extend(PostgreSQLConnectionFactory, superClass);
github ioBroker / ioBroker.sql / lib / mssql-client.js View on Github external
(function() {
    let ConnectionFactory = require('sql-client/lib/connection-factory').ConnectionFactory;
    let SQLClient = require('sql-client/lib/sql-client').SQLClient;
    let SQLClientPool = require('sql-client/lib/sql-client-pool').SQLClientPool;
    let mssql = require('mssql');

    let bind = function (fn, me){ return function (){ return fn.apply(me, arguments); }; };
    let extend = function (child, parent) { for (const key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
    let hasProp = {}.hasOwnProperty;
    let slice = [].slice;

    let MSSQLConnectionFactory = (function(superClass) {
        extend(MSSQLConnectionFactory, superClass);

        function MSSQLConnectionFactory() {
            this.execute = bind(this.execute, this);
            this.open_connection = bind(this.open_connection, this);
            return MSSQLConnectionFactory.__super__.constructor.apply(this, arguments);
        }
github ioBroker / ioBroker.sql / lib / mssql-client.js View on Github external
(function() {
    let ConnectionFactory = require('sql-client/lib/connection-factory').ConnectionFactory;
    let SQLClient = require('sql-client/lib/sql-client').SQLClient;
    let SQLClientPool = require('sql-client/lib/sql-client-pool').SQLClientPool;
    let mssql = require('mssql');

    let bind = function (fn, me){ return function (){ return fn.apply(me, arguments); }; };
    let extend = function (child, parent) { for (const key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
    let hasProp = {}.hasOwnProperty;
    let slice = [].slice;

    let MSSQLConnectionFactory = (function(superClass) {
        extend(MSSQLConnectionFactory, superClass);

        function MSSQLConnectionFactory() {
            this.execute = bind(this.execute, this);
            this.open_connection = bind(this.open_connection, this);
            return MSSQLConnectionFactory.__super__.constructor.apply(this, arguments);
        }
github ioBroker / ioBroker.sql / lib / postgresql-client.js View on Github external
(function() {
  var ConnectionFactory,  PostgreSQLClient, PostgreSQLClient2, PostgreSQLClientPool, PostgreSQLClientPool2, PostgreSQLConnectionFactory, PostgreSQLConnectionFactory2, SQLClient, SQLClientPool, pg,
    bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty,
    slice = [].slice;

  SQLClient = require('sql-client/lib/sql-client').SQLClient;

  SQLClientPool = require('sql-client/lib/sql-client-pool').SQLClientPool;

  ConnectionFactory = require('sql-client/lib/connection-factory').ConnectionFactory;

  pg = require('pg');
    try {
        if ((pg != null ? pg["native"] : void 0) != null) {
            pg = pg["native"];
        }
    } catch(err) {

    }


  PostgreSQLConnectionFactory = (function(superClass) {
github ioBroker / ioBroker.sql / main.js View on Github external
server:     msg.message.config.host,
        host:       msg.message.config.host,
        user:       msg.message.config.user,
        password:   msg.message.config.password
    };
    if (msg.message.config.port) {
        params.port = msg.message.config.port;
    }

    if (msg.message.config.dbtype === 'postgresql' && !SQL.PostgreSQLClient) {
        const postgres = require(__dirname + '/lib/postgresql-client');
        for (const attr in postgres) {
            if (!SQL[attr]) SQL[attr] = postgres[attr];
        }
    } else
    if (msg.message.config.dbtype === 'mssql' && !SQL.MSSQLClient) {
        const mssql = require(__dirname + '/lib/mssql-client');
        for (const _attr in mssql) {
            if (!SQL[_attr]) SQL[_attr] = mssql[_attr];
        }
    }

    if (msg.message.config.dbtype === 'postgresql') {
        params.database = 'postgres';
    } else if (msg.message.config.dbtype === 'sqlite') {
        params = getSqlLiteDir(msg.message.config.fileName);
    }
    let timeout;
    try {
        const client = new SQL[clients[msg.message.config.dbtype].name](params);
        timeout = setTimeout(() => {
            timeout = null;
github ioBroker / ioBroker.sql / main.js View on Github external
function testConnection(msg) {
    msg.message.config.port = parseInt(msg.message.config.port, 10) || 0;
    let params = {
        server:     msg.message.config.host,
        host:       msg.message.config.host,
        user:       msg.message.config.user,
        password:   msg.message.config.password
    };
    if (msg.message.config.port) {
        params.port = msg.message.config.port;
    }

    if (msg.message.config.dbtype === 'postgresql' && !SQL.PostgreSQLClient) {
        const postgres = require(__dirname + '/lib/postgresql-client');
        for (const attr in postgres) {
            if (!SQL[attr]) SQL[attr] = postgres[attr];
        }
    } else
    if (msg.message.config.dbtype === 'mssql' && !SQL.MSSQLClient) {
        const mssql = require(__dirname + '/lib/mssql-client');
        for (const _attr in mssql) {
            if (!SQL[_attr]) SQL[_attr] = mssql[_attr];
        }
    }

    if (msg.message.config.dbtype === 'postgresql') {
        params.database = 'postgres';
    } else if (msg.message.config.dbtype === 'sqlite') {
        params = getSqlLiteDir(msg.message.config.fileName);

sql-client

A dirt-simple SQL client abstraction (currently) supporting PostgreSQL, MySQL and SQLite.

MIT
Latest version published 3 years ago

Package Health Score

42 / 100
Full package analysis