Git Product home page Git Product logo

sync-mysql's People

Contributors

forbeslindesay avatar ravindra-rathor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sync-mysql's Issues

please add an option to get fields information

I want to access the fields property after I have made a query. In the normal async mysql package this would be the third argument passed into the callback of the query-function.

The current implementation always only returns the result-rows. To enable it to return both, the result-rows and the fields, the then-mysql package (also authored by you) would have to be changed as well. In connection.js only a small change would have to be made to the lines 45-47, so when the Promise is resolved it also returns the fields. However, in order not to break existing code, either a second version of the query-method would have to be added which is nearly a clone of the existing one, or you could add a parameter that defaults to the current behaviour, but can be configured so the promise returns e.g. an object like { result, fields }.

With that change in then-mysql, it would be easy to adapt sync-mysql to work with it.

I could write that myself and provide a PR, but I'm not sure in what style you would like the change to be implemented.

connection.escape

How can I escape a Query?

This doesn't work;

connection.query('SELECT * FROM channels WHERE  id = ' + connection.escape(id) + ' LIMIT 1');

can use multiple inserts?

Thanks for your toolkit.
can use multiple inserts?
connection.query("INSERT INTO table(title,content) VALUES ?", [ ['title', 'content'],[...] ])

How to get query result in addition to rows output?

It's a pretty dumb question, sorry. Still I do need to get the result, meaning what MySQL command line client would return as "<this many rows> were affected", or "Error: <error message>". Or, if you would, what the Workbench calls "Action Output". The regular node js means like the following:

db_conn.query('USE <db name>', (db_err, db_res) => {
if (db_err) {
console.log(db_err);
} else {
console.log(db_res);
}
});

... do not seem to be working here.

Thanks!

call procedure

Can You, please explain how to call the proc properly using your module? Thank You in advance!
For exmple i try to run the next:
db.call(procs.registration, "hello");
and have the next feedback from node:


TypeError: Expected args to be strings
    at Connection.call (/aut/ufo/node_modules/sync-mysql/lib/index.js:43:15)
    at Object.<anonymous> (/aut/ufo/lib/test.js:23:4)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

Write queries inside transaction

I wanted to write so many data to my database. I have written queries to write to different tables. Is there any possible way to put all the queries inside a transaction, so that I can commit/rollback the queries ?

The example in the README file is not working.

The example in the README file will throw an error:

TypeError: Expected args to be strings
    at Connection.query (/home/krm/dev/sync-mysql-test/node_modules/sync-mysql/lib/index.js:63:15)

However the code below will work:

var MySql = require('sync-mysql');
var assert = require('assert');

var connection = new MySql({
  host: 'localhost',
  user: 'me',
  password: 'secret'
});
 
const result = connection.query('SELECT 1 + 1 AS solution', []);
assert(result[0].solution==2);

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.