nodejs-mysql-native

Native mysql async client for node.js

Github星跟蹤圖

Deprecated . If you are using it, please consider migrating to node-mysql2

About

Mysql client module for node.js, written in JavaScript. No other mysql runtime required.

Build Status

Install

npm install mysql-native

Community

Check out the google group http://groups.google.com/group/node-mysql-native for questions/answers from users of the driver.

Example

output is:
row: [ 2, 2, 3, "4", 5]
row: [ 2, 2, 3, "4", 5]

Highlights

  • commands are pipelined
  • types are converted mysql<->javascript according to field type
  • prepared statements are cached and auto-prepared
  • row packet ( query ) and binary row packet ( execute ) handled transparently equal

#API

Module Functions

  • createClient(socket) - create client from duplex stream (TODO: add default path to local server socket)
  • createTCPClient(host, port) - create tcp client, default host 127.0.0.1, port 3306
  • createUNIXClient(path) - connect to unix domain socket, default is /var/run/mysqld/mysqld.sock

Client Functions

All commands fire 'end'() event at the end of command executing.

  • auth(db, user, pass) - perform mysql connection handshake. Should be always a first command (TODO: add default user/pass if missing?).
    Events:
    'authorized'(serverStatus) event.

  • query(sql) - simple query.
    Events:
    'field'(field) - one for each field description
    'fields_eof'() - after last field
    'row'(rows) - array of field values, fired for each row in result set

  • client.prepre(sql) - prepare a statement and store result in client.pscache
    Events:
    'prepared'(preparedStatement)
    'parameter'(field) - input parameter description

  • execute(sql, parameters) - parameters is an array of values. Known types are sent in appropriate mysql binary type (TODO: currently this is not true, type is always string and input converted using param.toString() )
    Events:
    same as with query()

  • client.close - create and enqueue corresponding command

  • client.execute also adds prepare command if there is no cached statement and client.auto_prepare set to true (TODO: add better api than client.auto_prepare flag)

  • client.terminate - close conection immediately

TODO

  • buffers

LINKS

MySql protocol documentation:

Other node.js mysql clients:

Bitdeli Badge

主要指標

概覽
名稱與所有者sidorares/nodejs-mysql-native
主編程語言JavaScript
編程語言JavaScript (語言數: 1)
平台
許可證MIT License
所有者活动
創建於2010-02-15 14:44:45
推送於2018-05-17 09:55:33
最后一次提交2014-02-22 07:57:02
發布數8
最新版本名稱v0.4.3 (發布於 )
第一版名稱list (發布於 )
用户参与
星數245
關注者數14
派生數34
提交數200
已啟用問題?
問題數58
打開的問題數21
拉請求數16
打開的拉請求數4
關閉的拉請求數3
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?