{"id":17652646,"url":"https://github.com/sidorares/nodejs-mysql-native","last_synced_at":"2025-04-06T07:14:03.167Z","repository":{"id":811167,"uuid":"518791","full_name":"sidorares/nodejs-mysql-native","owner":"sidorares","description":"Native mysql async client for node.js","archived":false,"fork":false,"pushed_at":"2018-05-17T09:55:33.000Z","size":210,"stargazers_count":245,"open_issues_count":25,"forks_count":34,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-03-30T06:06:38.294Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sidorares.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-02-15T14:44:45.000Z","updated_at":"2025-02-05T19:53:55.000Z","dependencies_parsed_at":"2022-08-16T11:00:19.334Z","dependency_job_id":null,"html_url":"https://github.com/sidorares/nodejs-mysql-native","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidorares%2Fnodejs-mysql-native","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidorares%2Fnodejs-mysql-native/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidorares%2Fnodejs-mysql-native/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidorares%2Fnodejs-mysql-native/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sidorares","download_url":"https://codeload.github.com/sidorares/nodejs-mysql-native/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246752317,"owners_count":20827982,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-23T11:47:33.446Z","updated_at":"2025-04-06T07:14:03.145Z","avatar_url":"https://github.com/sidorares.png","language":"JavaScript","readme":"# Deprecated . If you are using it, please consider migrating to [node-mysql2](https://github.com/sidorares/node-mysql2)\n\n# About\nMysql client module for node.js, written in JavaScript. No other mysql runtime required.\n\n[![Build Status](https://secure.travis-ci.org/sidorares/nodejs-mysql-native.png)](http://travis-ci.org/sidorares/nodejs-mysql-native)\n\n# Install\n`npm install mysql-native`\n\n# Community\nCheck out the google group http://groups.google.com/group/node-mysql-native for questions/answers from users of the driver.\n\n\n# Example\n\u003cpre\u003evar db = require(\"mysql-native\").createTCPClient(); // localhost:3306 by default\ndb.auto_prepare = true;\nfunction dump_rows(cmd)\n{\n   cmd.addListener('row', function(r) { console.dir(r); } );\n}\n\ndb.auth(\"test\", \"testuser\", \"testpass\");\ndump_rows(db.query(\"select 1+1,2,3,'4',length('hello')\"));\ndump_rows(db.execute(\"select 1+1,2,3,'4',length(?)\", [\"hello\"]));\ndb.close();\u003c/pre\u003e\n\noutput is:\nrow: [ 2, 2, 3, \"4\", 5]\nrow: [ 2, 2, 3, \"4\", 5]\n\n# Highlights\n\n* commands are pipelined\n* types are converted mysql\u003c-\u003ejavascript according to field type\n* prepared statements are cached and auto-prepared\n* row packet ( query ) and binary row packet ( execute ) handled transparently equal\n\n#API\n\n## Module Functions\n* createClient(socket) -  create client from duplex stream (TODO: add default path to local server socket)\n* createTCPClient(host, port) - create tcp client, default host 127.0.0.1, port 3306\n* createUNIXClient(path) - connect to unix domain socket, default is /var/run/mysqld/mysqld.sock\n\n## Client Functions\nAll commands fire 'end'() event at the end of command executing.\n\n* `auth(db, user, pass)` - perform mysql connection handshake. Should be always a first command (TODO: add default user/pass if missing?).\nEvents:\n    'authorized'(serverStatus) event. \n\n* `query(sql)` - simple query.\nEvents:\n    'field'(field) - one for each field description\n    'fields_eof'() - after last field\n    'row'(rows) - array of field values, fired for each row in result set\n\n* `client.prepre(sql)` - prepare a statement and store result in client.pscache\nEvents:\n    'prepared'(preparedStatement)\n    'parameter'(field) - input parameter description\n\n* `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() )\nEvents:\n   same as with query()\n   \n* `client.close` - create and enqueue corresponding command\n* `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)\n* `client.terminate` - close conection immediately\n\n# TODO\n\n* buffers \n\n# LINKS\n\nMySql protocol documentation:\n \n* \u003chttp://dev.mysql.com/doc/internals/en/client-server-protocol.html\u003e\n\nOther node.js mysql clients:\n\n* \u003chttp://github.com/felixge/node-mysql\u003e\n* \u003chttp://github.com/Sannis/node-mysql-libmysqlclient\u003e\n* \u003chttp://github.com/Guille/node.dbslayer.js\u003e\n\n\n[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/sidorares/nodejs-mysql-native/trend.png)](https://bitdeli.com/free \"Bitdeli Badge\")\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsidorares%2Fnodejs-mysql-native","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsidorares%2Fnodejs-mysql-native","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsidorares%2Fnodejs-mysql-native/lists"}