Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mysql-client

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mysql-client

A full-featured mysql client for node

  • 0.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

MySQL Client for node.js

This MySQL implementation supports some basic MySQL protocol commands. I plan to support the full MySQL protocol except the deprecated parts.

Basic Usage

var Connection = require('./lib/Connection').Connection;
var myCon = new Connection('user', 'pass');

myCon.on('authenticated', function() {
	myCon.selectDb('test'); // Even tough the querys are asynchronous, this is possible (through query-queue)
	myCon.query('SELECT * FROM foo', function(err, packet) {
		console.log(packet);
	});
});

Options

boolean Connection.prototype.options.bufferRows

Decides, if rows should get buffered

boolean Connection.prototype.options.autoBox

Converts the MySQL datatypes to javascript datatypes automatically.

{0, 1, 2} Connection.prototype.options.fetchMode

Decides the fetchmode.

  • 0 ... Fetch numeric. Just a basic array. Accessible through row[0]
  • 1 ... Fetch assoc. An object, every column is a key. Accessible through row['column']
  • 2 ... Fetch array. A combination of the two above. Accessible through both ways.

API

Connection([string user[, string password[, string host[, number port]]]])

Creates a connection and tries to connect/authorize to the database

Connection.prototype.connect()

Connects to the database, if the first attempt wasn't successful/the connection got destroyed

Connection.prototype.close(function(string err, ParseablePacket pp) listener)

Closes the connection to the database through the mysql_close command. Fires off listener, after a result.

Connection.prototype.destroy()

Destroys the socket to the database immediatly. No more reads/writes will be possible.

Connection.prototype.selectDb(string db, function(string err, ParseablePacket pp) listener)

Selects a database. Fires off listener after a result of the database.

Connection.prototype.query(string cmd, function(string err, Array.<Object.<*>> rows) listener, function(ColumnPacket cp) columnCb, function(Object.<*> data) rowCb)

Sends a query to the database. Fires off listener after a full result/error of the database. If no error occured and buffering rows is activated, rows contains every row. Fires columnCb for every received column entry; fires rowCb for every received row.

Events

drain

Fired, when all querys are executed and all result sets are received.

authenticated

Fired, when the authentication was successful.

error

Fired, when the authentication wasn't successful (will maybe have more meanings; for example when the connection is destroyed/not accessible anymore)

FAQs

Package last updated on 14 Mar 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc