{"id":42851,"library":"highsql","title":"highsql: High-level MySQL Utility","description":"Highsql is a TypeScript module that provides a high-level MySQL database utility built on top of mysql2/promise. Version 1.3.3 offers a promise-based interface with connection pooling, prepared statements, and convenience methods for common operations (SELECT, INSERT, UPDATE, DELETE) and transactions. Unlike raw mysql2 usage, highsql simplifies query construction and error handling with custom error classes. The library targets TypeScript developers who need a readable, secure wrapper without an ORM. Active development is moderate; the package has low weekly downloads and no recent releases, suggesting a maintenance phase. Key differentiators: built-in transaction scope, getByID shorthand, and underlying pool access.","status":"active","version":"1.3.3","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install highsql","lang":"bash","label":"npm"},{"cmd":"yarn add highsql","lang":"bash","label":"yarn"},{"cmd":"pnpm add highsql","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core database driver; highsql wraps mysql2's promise API and expects it to be installed separately.","package":"mysql2","optional":false}],"imports":[{"note":"ESM-only; require() will fail. Types come with the package (.d.ts).","wrong":"const Connection = require('highsql')","symbol":"Connection","correct":"import { Connection } from 'highsql'"},{"note":"Type for config object. Also ESM-only.","wrong":"const { ConnectionConfig } = require('highsql')","symbol":"ConnectionConfig","correct":"import { ConnectionConfig } from 'highsql'"},{"note":"Re-exported from mysql2; type only.","wrong":"Import from 'mysql2' (unnecessary)","symbol":"RowDataPacket","correct":"import { RowDataPacket } from 'highsql'"}],"quickstart":{"code":"import { Connection, ConnectionConfig } from 'highsql'\n\nasync function main() {\n  const config: ConnectionConfig = {\n    host: process.env.DB_HOST ?? 'localhost',\n    user: process.env.DB_USER ?? 'root',\n    password: process.env.DB_PASSWORD ?? '',\n    database: 'test'\n  }\n  const conn = new Connection(config)\n  \n  const rows = await conn.select('users', 'id, name', 'id = ?', [1])\n  console.log(rows)\n  \n  await conn.insert('users', { name: 'Alice', email: 'alice@example.com' })\n  await conn.update('users', { email: 'alice@new.com' }, 'id = ?', [1])\n  await conn.delete('users', 'id = ?', [1])\n  \n  await conn.transaction(async (tx) => {\n    await tx.insert('orders', { user_id: 1, total: 100 })\n    await tx.update('users', { balance: 900 }, 'id = ?', [1])\n  })\n  \n  await conn.close()\n}\n\nmain().catch(console.error)","lang":"typescript","description":"Demonstrates creating a connection, basic CRUD operations, and a transaction with highsql."},"warnings":[{"fix":"Always validate config object completeness before instantiation.","message":"The Connection constructor expects a plain object; ensure all required fields (host, user, password, database) are provided. Missing fields may cause silent failures or pool errors.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Use conn.close() instead of manually closing the pool.","message":"The getPool() method returns the underlying mysql2 Pool, but note that highsql's own methods use it internally; closing the pool via pool.end() directly can break highsql's state.","severity":"deprecated","affected_versions":">=1.0"},{"fix":"Ensure your callback is async or returns a promise: async (conn) => { ... }","message":"The `transaction` method requires a callback that returns a Promise; if you forget to return the promise chain, the transaction may commit prematurely.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Use rows.length === 0 to detect empty result.","message":"The `select` method returns RowDataPacket[]; if no rows match, it returns an empty array, not null. Check array length before accessing elements.","severity":"gotcha","affected_versions":">=1.0"}],"env_vars":null,"search_vec":"'1.3.3':27 'access':110 'activ':80 'base':32 'built':21,101 'built-in':100 'class':65 'common':43 'connect':35 'construct':58 'conveni':40 'custom':63 'databas':19 'delet':48 'develop':70,81 'differenti':99 'download':89 'error':60,64 'getbyid':105 'handl':61 'high':3,16 'high-level':2,15 'highsql':1,7,55 'insert':46 'interfac':33 'javascript':111 'key':98 'level':4,17 'librari':67 'low':87 'mainten':96 'method':41 'moder':83 'modul':11 'mysql':5,18 'mysql2':53 'mysql2/promise':25 'need':72 'offer':28 'oper':44 'orm':79 'packag':85 'phase':97 'pool':36,109 'prepar':37 'promis':31 'promise-bas':30 'provid':13 'queri':57 'raw':52 'readabl':74 'recent':92 'releas':93 'scope':104 'secur':75 'select':45 'shorthand':106 'simplifi':56 'statement':38 'suggest':94 'target':68 'top':23 'transact':50,103 'typescript':10,69 'under':108 'unlik':51 'updat':47 'usag':54 'util':6,20 'version':26 'week':88 'without':77 'wrapper':76","created_at":"2026-06-05T16:56:58.354337+00:00","updated_at":"2026-06-05T16:56:58.354337+00:00","problems":[{"fix":"Instead, create a plain object: const config: ConnectionConfig = { host: '...', user: '...', password: '...', database: '...' }","cause":"Using `new ConnectionConfig()` as if it were a constructor; ConnectionConfig is an interface/type, not a class.","error":"TypeError: ConnectionConfig is not a constructor"},{"fix":"Ensure you have run `npm install highsql mysql2` and added `import { Connection } from 'highsql'`.","cause":"Missing import or incorrect path; highsql is installed but not imported.","error":"Cannot find name 'Connection'. Did you mean 'mysql2'?"},{"fix":"Run `npm install highsql` and check your import path: `import { Connection } from 'highsql'`","cause":"highsql is not installed, or you are using a path instead of package name.","error":"Error: Cannot find module 'highsql'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"highsql","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}