{"id":44155,"library":"xsql","title":"XSQL SQL Query Builder","description":"XSQL is a SQL query builder library for Node.js supporting MySQL, MariaDB, SQLite, and PostgreSQL dialects. Version 1.0.1 provides a programmatic API to construct SQL queries using helper methods like x.select(), x.from(), x.where(), and x.join(). It handles identifier quoting, table aliasing, and schema prefixes per dialect. The library is minimal, has no dependencies, and focuses on building SELECT, INSERT, UPDATE, DELETE queries with nested functions, joins, and conditions. Released under MIT license, it receives infrequent updates. Compared to knex.js or squel, XSQL is lighter but requires more manual query assembly via string concatenation.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"git://github.com/simov/xsql","tags":["javascript","sql","query","builder","mysql","mariadb","sqlite","postgresql","pg"],"install":[{"cmd":"npm install xsql","lang":"bash","label":"npm"},{"cmd":"yarn add xsql","lang":"bash","label":"yarn"},{"cmd":"pnpm add xsql","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package provides ESM default export; CommonJS require works but TypeScript may need esModuleInterop.","wrong":"const Xsql = require('xsql')","symbol":"default","correct":"import Xsql from 'xsql'"},{"note":"Constructor accepts dialect and optional schema. Instance methods are used to build queries.","symbol":"constructor","correct":"const x = new Xsql({dialect: 'mysql'})"},{"note":"No named type exports; use default for runtime and typeof for types if needed.","wrong":"import { Xsql } from 'xsql'","symbol":"types (TypeScript)","correct":"import type { XsqlInstance } from 'xsql'"}],"quickstart":{"code":"import Xsql from 'xsql'\nconst x = new Xsql({dialect: 'mysql'})\nconst query = [\n  x.select(x.names(['col1','col2'],'tbl')),\n  x.from(x.name('tbl')),\n  x.where(x.eq(x.name('id','tbl'),2)),\n  ';'\n].join(' ')\nconsole.log(query)\n// Output: select `tbl`.`col1`,`tbl`.`col2` from `tbl` where `tbl`.`id`=2 ;","lang":"javascript","description":"Constructs a SELECT query with columns and WHERE condition, outputting quoted identifiers for MySQL."},"warnings":[{"fix":"Always call new Xsql({...}) before using method chaining.","message":"All methods must be called as instance methods; forgetting 'new' when constructing leads to errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use import Xsql from 'xsql' instead of destructuring.","message":"Cannot use named imports; only default export is available.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider knex.js or squel for active maintenance and more features.","message":"No deprecation notices yet. The package is stable but receives infrequent updates.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Pass dialect option: 'mysql', 'mariadb', 'sqlite', 'postgresql', or 'pg'.","message":"Identifier quoting varies by dialect; explicit dialect must be provided.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Only use schema with 'pg' or 'postgresql' dialect.","message":"Schema prefixes are ignored on non-PostgreSQL dialects; using x.schema('z') on MySQL produces no prefix.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.1':22 'alias':45 'api':26 'assembl':94 'build':61 'builder':4,10,101 'compar':81 'concaten':97 'condit':72 'construct':28 'delet':65 'depend':57 'dialect':20,50 'focus':59 'function':69 'handl':41 'helper':32 'identifi':42 'infrequ':79 'insert':63 'javascript':98 'join':70 'knex.js':83 'librari':11,52 'licens':76 'lighter':88 'like':34 'manual':92 'mariadb':16,103 'method':33 'minim':54 'mit':75 'mysql':15,102 'nest':68 'node.js':13 'per':49 'pg':106 'postgresql':19,105 'prefix':48 'programmat':25 'provid':23 'queri':3,9,30,66,93,100 'quot':43 'receiv':78 'releas':73 'requir':90 'schema':47 'select':62 'sql':2,8,29,99 'sqlite':17,104 'squel':85 'string':96 'support':14 'tabl':44 'updat':64,80 'use':31 'version':21 'via':95 'x.from':36 'x.join':39 'x.select':35 'x.where':37 'xsql':1,5,86","created_at":"2026-06-05T17:03:14.756316+00:00","updated_at":"2026-06-05T17:03:14.756316+00:00","problems":[{"fix":"import Xsql from 'xsql'; const x = new Xsql({dialect:'mysql'});","cause":"Using named import instead of default import, or failing to use 'new'.","error":"TypeError: Xsql is not a constructor"},{"fix":"npm install xsql","cause":"Package not installed or not in node_modules.","error":"Cannot find module 'xsql'"},{"fix":"Ensure calling new Xsql() and storing result in a variable.","cause":"Instance not created with 'new' or using namespace instead of instance.","error":"TypeError: x.select is not a function"},{"fix":"Use x.escape() for values, or manually add quotes with proper escaping.","cause":"String literals in SQL not properly escaped; x.wrap() only for identifiers.","error":"Unclosed quotation mark"}],"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/simov/xsql","github":"git://github.com/simov/xsql","docs":null,"changelog":null,"pypi":null,"npm":"xsql","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}}