{"id":43373,"library":"mysql-with-kysely","title":"mysql-with-kysely","description":"Integration library connecting MySQL (via mysql2) with the Kysely query builder. v0.2.2 released 2023-10, handles MySQL BIGINT as string, provides type-safe query building with TypeScript, and includes a plugin to fix the 'Incorrect arguments to mysqld_stmt_execute' error from MySQL 8.0.22+. Ships TypeScript types, depends on kysely ^0.18.1 and mysql2 ^2.3.3. Compared to raw mysql2, it offers full Kysely integration with subscription to query metrics and mock helpers for testing.","status":"active","version":"0.2.2","language":"javascript","source_language":"en","source_url":"https://github.com/kanziw/mysql-with-kysely","tags":["javascript","mysql","kysely","query builder","Incorrect arguments to mysqld_stmt_execute","kanziw","typescript"],"install":[{"cmd":"npm install mysql-with-kysely","lang":"bash","label":"npm"},{"cmd":"yarn add mysql-with-kysely","lang":"bash","label":"yarn"},{"cmd":"pnpm add mysql-with-kysely","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for query building","package":"kysely","optional":false},{"reason":"peer dependency for MySQL connection","package":"mysql2","optional":false}],"imports":[{"note":"ESM-only, no default export","wrong":"const connect = require('mysql-with-kysely').connect","symbol":"connect","correct":"import { connect } from 'mysql-with-kysely'"},{"note":"Named function, not a class","wrong":"import QueryBuilder from 'mysql-with-kysely'","symbol":"queryBuilder","correct":"import { queryBuilder } from 'mysql-with-kysely'"},{"note":"PascalCase type, not camelCase","wrong":"import { withSchema } from 'mysql-with-kysely'","symbol":"WithSchema","correct":"import { WithSchema } from 'mysql-with-kysely'"},{"note":"Type helper, use with 'type' keyword in ts","wrong":"","symbol":"toInsertableSchema","correct":"import { toInsertableSchema } from 'mysql-with-kysely'"},{"note":"exported from subpath 'mysql-with-kysely/test'","wrong":"import { createMockMySqlHelper } from 'mysql-with-kysely'","symbol":"createMockMySqlHelper","correct":"import { createMockMySqlHelper } from 'mysql-with-kysely/test'"}],"quickstart":{"code":"import { connect, queryBuilder, WithSchema, toFullSelectableSchema, toInsertableSchema } from 'mysql-with-kysely';\n\ntype Database = { user: WithSchema<{ id: number; name: string; email: string }> };\ntype SelectableUser = toFullSelectableSchema<Database>['user'];\ntype InsertableUser = toInsertableSchema<Database>['user'];\n\nconst { db, close } = connect<Database>({ uri: 'mysql://root:root@localhost:3306/test' });\n\nconst qb = queryBuilder<Database>();\n\nasync function main() {\n  const users = await db.query(qb.selectFrom('user').selectAll().orderBy('id', 'desc').limit(1));\n  console.log(users);\n  const value: InsertableUser = { name: 'kanziw', email: 'kanziwoong@gmail.com' };\n  const { insertId } = await db.execute(qb.insertInto('user').values(value));\n  console.log(insertId);\n  await close();\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Connects to MySQL, defines typed schema, runs select and insert queries via Kysely, then closes connection."},"warnings":[{"fix":"npm install kysely@^0.18.1 mysql2@^2.3.3","message":"Requires peer dependencies kysely@^0.18.1 and mysql2@^2.3.3 to be installed separately","severity":"gotcha","affected_versions":">=0.2.0"},{"fix":"Use db.query() and db.execute() instead of db.selectFrom() directly","message":"connect() returns an object with db and close; db is the query executor, not the standard Kysely database instance","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"Handle BIGINT columns as strings in TypeScript types","message":"BIGINT values are cast to string to avoid precision loss","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use toSelectableSchema<Database>['user'] to omit lifecycle fields","message":"toFullSelectableSchema includes created_at and updated_at fields; use toSelectableSchema if those are not needed","severity":"breaking","affected_versions":">=0.2.0"}],"env_vars":null,"search_vec":"'-10':19 '0.18.1':56 '2.3.3':59 '2023':18 '8.0.22':49 'argument':41,85 'bigint':22 'build':30 'builder':15,83 'compar':60 'connect':7 'depend':53 'error':46 'execut':45,89 'fix':38 'full':66 'handl':20 'helper':76 'includ':34 'incorrect':40,84 'integr':5,68 'javascript':79 'kanziw':90 'kyse':4,13,55,67,81 'librari':6 'metric':73 'mock':75 'mysql':2,8,21,48,80 'mysql-with-kys':1 'mysql2':10,58,63 'mysqld':43,87 'offer':65 'plugin':36 'provid':25 'queri':14,29,72,82 'raw':62 'releas':17 'safe':28 'ship':50 'stmt':44,88 'string':24 'subscript':70 'test':78 'type':27,52 'type-saf':26 'typescript':32,51,91 'v0.2.2':16 'via':9","created_at":"2026-06-05T16:59:29.476287+00:00","updated_at":"2026-06-05T16:59:29.476287+00:00","problems":[{"fix":"npm install mysql-with-kysely","cause":"Package not installed or missing","error":"Cannot find module 'mysql-with-kysely'"},{"fix":"Use mysql-with-kysely which includes the OffsetLimitTypeCastingPlugin to fix this","cause":"MySQL 8.0.22+ bug with prepared statements and big integers","error":"Incorrect arguments to mysqld_stmt_execute"},{"fix":"Use the db returned from connect(), which has query() and execute() methods, not the standard Kysely instance","cause":"Confusing Kysely's db instance with mysql-with-kysely's db wrapper","error":"Property 'query' does not exist on type 'Kysely<Database>'"},{"fix":"Use WithSchema which handles BIGINT as string, or cast with Number()","cause":"BIGINT is returned as string; TypeScript expects number","error":"Type 'string' is not assignable to type 'number'"}],"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":"https://github.com/kanziw/mysql-with-kysely#readme","github":"https://github.com/kanziw/mysql-with-kysely","docs":null,"changelog":null,"pypi":null,"npm":"mysql-with-kysely","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}}