{"id":20613991,"url":"https://github.com/evanpatchouli/evanpatchouli-mysql","last_synced_at":"2026-04-28T16:35:48.840Z","repository":{"id":65346439,"uuid":"587782566","full_name":"Evanpatchouli/evanpatchouli-mysql","owner":"Evanpatchouli","description":"Node.js SQL tool for MySQL, which can help you use MySQL easier in node.js","archived":false,"fork":false,"pushed_at":"2023-04-18T08:32:47.000Z","size":8035,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-18T07:16:40.843Z","etag":null,"topics":["mysql","nodejs","tool"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Evanpatchouli.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2023-01-11T15:19:44.000Z","updated_at":"2023-04-18T15:33:54.000Z","dependencies_parsed_at":"2023-02-12T03:01:39.642Z","dependency_job_id":null,"html_url":"https://github.com/Evanpatchouli/evanpatchouli-mysql","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Evanpatchouli%2Fevanpatchouli-mysql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Evanpatchouli%2Fevanpatchouli-mysql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Evanpatchouli%2Fevanpatchouli-mysql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Evanpatchouli%2Fevanpatchouli-mysql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Evanpatchouli","download_url":"https://codeload.github.com/Evanpatchouli/evanpatchouli-mysql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242268662,"owners_count":20100067,"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":["mysql","nodejs","tool"],"created_at":"2024-11-16T11:11:35.984Z","updated_at":"2026-04-28T16:35:48.781Z","avatar_url":"https://github.com/Evanpatchouli.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# evanpatchouli-mysql\n\nevanpatchouli-mysql is js-tool for MySQL, whick can help you use MySQL easier in node.\n\nThis tool is at birth and it will grow up fastly in the future.\n\n# Latest Version: 1.0.22\n\n**v1.0.22**:\n- now you can create and use more connection pool rather than only the one default pool.\n- improve the HELP.md.\n- improve the type hint.\n\n**v1.0.21**: a patch\n\n**v1.0.20**:\n- Intelligent Hint\nType declared with typescript so that the intelligent coding hint is supported.\n- 1 Bug Fixed\nThe bug of lifetime of conn is fixed.\n\n**v1.0.18**: add two functions: **newDb** and **delDb**\n\n**v1.0.17**: a patch, export bug has been fixed\n\n**v1.0.16**: a patch\n\n**v1.0.15**: a patch\n\n**v1.0.14**: a patch\n\n**v1.0.13**: \n\n**JsDoc** has been added!\n\n**v1.0.12**: \n\n**Compiled into CommonJs:** since v1.0.11, the sql.js module will be compiled into commonjs by babel, and you can enjoy it with both of cjs and mjs. \n\n**Standardlize:** the function name in conn, pool and db. One of my friend told me that the name \"get\" confused him to think it as \"get a connection\", and this is just when I realized that I should make the names more clear and easy at the same time.\n\n**One New Feature:** the db has mode! It has two options: \"debug\" and \"non-debug\", you can set it at db.mode, the \"non-debug\" mode only returns one of the entire mysql.js result, and \"debug\" mode returns entirely, with the sql str and some message printed in console working like sql log.\n\n**One New Change:** under \"non-debug\" mode, the action like **update**, **insert**, **delete** will all return one number, and the meanings are a bit different between them: **upd**, return the result = affectedRows + changedRows - 1, and it's easy to understand the three value of it, 1 means success, 0 means the new is the same as new, -1 means the target record doesn't exist.**insert** and **delete** return affectedRows, 1 means success and 0 instead.\n\n# Install\n\n```shell\nnpm install evanpatchouli-mysql\n```\n\n# Code Resource\nhttps://github.com/Evanpatchouli/evanpatchouli-mysql\n\n# Useage\n\n**Tip:** the sql-action is a packaged Promise, I suggest to use **'async / await'**, but raw Promise also works if you prefer it.\n\n## Separate Introduction\ntype: \"Moudle\"  \n\n```javascript\nimport db from \"evanpatchouli-mysql/lib/sql.js\";\n```\n\ntype: \"CommonJs\"  \n\n```javascript\nlet db = require(\"../index.js\");\n```\n\n\n### quick sql\n\n```javascript\nlet result = db.sel('select * from user');\n```\n\n### sql in a quick persistent conn\n\n```javascript\nlet conn = await db.conn(\"localhost\", 3306, \"root\", \"root\", \"springdemo\");\nlet result = conn.get('select * from user');\n```\n\n### close a conn\n\n```javascript\nconn.close();\n```\n\n### init connection pool\n\n```javascript\n// example db.pool.init(host, port, user, password, database)\ndb.pool.init('localhost',3306,'root','root','springdemo');\n```\n\n### quick sql in pool\n\n```javascript\nlet result = db.pool.sel('select * from user')\n```\n\n### do sql in a certain conn in pool\n\n```javascript\nlet conn = db.pool.conn();\nlet result = conn.sel('select * from user')\n```\n\n### close pool\n\n```javascript\ndb.pool.close();\n```\n\n### Result : Output\n\n**debug mode output:**\n\n```javascript\nsql: insert into user (name,pwd) values ('user3','userpwd')\nunder: springdemo\nconnection: conn1 in pool persistent\n{\n  sql: \"insert into user (name,pwd) values ('user3','userpwd')\",\n  res: {\n    fieldCount: 0,\n    affectedRows: 1,\n    insertId: 17,\n    serverStatus: 2,\n    warningCount: 0,\n    message: '',\n    protocol41: true,\n    changedRows: 0\n  }\n}\n```\n\n## More\n\nMore usage can be saw in HELP.md","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevanpatchouli%2Fevanpatchouli-mysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevanpatchouli%2Fevanpatchouli-mysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevanpatchouli%2Fevanpatchouli-mysql/lists"}