GithubHelp home page GithubHelp logo

sungwoncho / sync-sql Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cristidraghici/sync-sql

0.0 2.0 0.0 11 KB

sync-sql is designed to make synchronous queries to the database.

License: MIT License

JavaScript 100.00%

sync-sql's Introduction

sync-sql

sync-sql is designed to make synchronous queries to the database. It has been developed as a tool to help nightwatch.js tests - or other such tools - connect directly to an sql database.

Important note

!!! You should not be using this in a production evironment. Node.js is designed to be asynchronous, therefore running sync queries on the database will seriously impact performance and stability.

Install

npm install sync-sql

For using the latest version with bug fixes, try the command:

npm install cristidraghici/sync-sql

Example usage with mysql

var syncSql = require('sync-sql');

var output = syncSql.mysql(
	{
		host: 'localhost',
		user: 'user',
		pass: 'password',
		database: 'database',
		port: '3306'
	},
	"select * from users"
);

console.log(JSON.stringify(output));

Testing

  • please edit the .env.example with database information and the sql to test and save the file as .env;
  • run npm install;
  • run npm run test-mysql;
  • run npm run test-pg;
  • run npm run test.

Workflow

Internally, this uses a separate worker process that is run using childProcess.spawnSync.

The worker then makes the actual query using the mysql and pg packages.

Thanks

Thanks to sync-request / Forbes Lindesay for providing the base knowledge for this package.

License

MIT

sync-sql's People

Contributors

cristidraghici avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.