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

mariasql

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mariasql

A node.js binding to MariaDB's non-blocking (MySQL) client library

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10K
decreased by-6.49%
Maintainers
1
Weekly downloads
 
Created
Source

Description

A node.js binding to MariaDB's non-blocking (MySQL) client library.

This binding is different from other vanilla libmysqlclient bindings in that it uses the non-blocking functions available in MariaDB's client library.

Therefore, this binding does not use multiple threads to achieve non-blocking behavior.

This binding is currently tested on Windows and Linux.

Requirements

  • node.js -- v0.8.0 or newer

  • *nix users need to install the libmariadbclient-dev package (must be 5.5.x+). Linux users can get this from the MariaDB repositories.

Install

npm install mariasql

Examples

  • Simple query to retrieve a list of all databases:
var inspect = require('util').inspect;
var Client = require('mariasql');
var c = new Client();

c.on('connect', function() {
  console.log('Connected!');

  var q = c.query("SHOW DATABASES");

  q.on('result', function(result) {
    console.log('Query result: ' + inspect(result));
  });

  q.on('error', function(err) {
    console.log('Query error: ' + err);
  });

  q.on('end', function() {
    console.log('Query finished');
    c.close();
  });
});

c.on('error', function(err) {
  console.log('Client error: ' + err);
});

c.on('close', function(had_err) {
  console.log('Closed');
});

c.connect({
  host: '127.0.0.1',
  user: 'foo',
  password: 'bar'
});

API

require('mariasql') returns a Client object

Client events

  • connect() - A connection to the server was successful.

  • error(<Error>err) - An error occurred at the connection level.

  • close(<boolean>hadError) - The connection was closed. hadError is set to true if this was due to a connection-level error.

Client methods

  • (constructor)() - Creates and returns a new Client instance.

  • connect(<object>config) - (void) - Attempts a connection to a server using the information given in config:

    • user - <string> - Username for authentication. Default: (*nix: current login name, Windows: ???)

    • password - <string> - Password for authentication. Default: (blank password)

    • host - <string> - Hostname or IP address of the MySQL/MariaDB server. Default: "localhost"

    • port - <integer> - Port number of the MySQL/MariaDB server. Default: 3306

    • db - <string> - A database to automatically select after authentication Default: (no db)

  • query(<string>query) - <EventEmitter> - Enqueues the given query and returns an EventEmitter that emits the following when the query is executed:

    • result(<object>res) - res is an object of fieldName=>value pairs, where value is a string.

    • end() - No more results for this query.

    • error(<Error>err) - An error occurred while executing this query.

  • escape(<string>value) - Escapes value for use in queries. This method requires a live connection.

  • close(<boolean>immediately) - If immediately is true, the connection is severed even if other queries are still in the queue.

TODO

  • Multiple statement (e.g. "SELECT * FROM foo; SELECT * FROM bar" vs. "SELECT * FROM foo") support

  • Compression

  • SSL encrypted connections

  • Misc. query info (e.g. affected_rows, insert_id, etc)

  • Auto-reconnect algorithm(s)

  • Array-based query results option instead of being forced into a fieldName=>value object

  • Possibly some other stuff I'm not aware of at the moment

Keywords

FAQs

Package last updated on 19 Aug 2012

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