{"id":42678,"library":"edge-sql","title":"edge-sql","description":"Edge-sql is an ADO.NET-based SQL compiler for Edge.js, enabling Node.js applications to access MS SQL, MySQL, and PostgreSQL databases via C#/CLR. As of v1.0.6, it supports .NET 4.6.2 (except PostgreSQL) and .NET Core/netstandard2.0, with optional environment variable or runtime connection strings. It automatically interprets SQL statement types (SELECT as data reader, UPDATE as non-query) and returns multiple result sets. Unlike pure JavaScript drivers, it bridges Node.js and .NET for scenarios where ADO.NET is preferred.","status":"active","version":"1.0.6","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/agracio/edge-sql","tags":["javascript","edge","edgejs","edge.js","edge-js","net","clr","c#","managed"],"install":[{"cmd":"npm install edge-sql","lang":"bash","label":"npm"},{"cmd":"yarn add edge-sql","lang":"bash","label":"yarn"},{"cmd":"pnpm add edge-sql","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required runtime; edge-sql is a compiler that plugs into Edge.js to execute SQL via .NET.","package":"edge-js","optional":false}],"imports":[{"note":"edge-sql is not imported directly; it's a compiler loaded by edge.func with 'sql' as the language parameter.","wrong":"const getUsers = require('edge-sql');","symbol":"edge.func","correct":"const edge = require('edge-js'); const getUsers = edge.func('sql', function () {/* ... */});"},{"note":"Connection string is set via environment variable or passed as an option to edge.func; edge-sql does not export a setter.","wrong":"const edge = require('edge-sql').setConnectionString('...');","symbol":"connectionString (env var)","correct":"process.env.EDGE_SQL_CONNECTION_STRING = 'Data Source=...';"},{"note":"When passing options, use an object with source, connectionString, etc. The first parameter is the language ('sql') or an options object.","wrong":"edge.func('sql', { connectionString: '...' });","symbol":"Options object","correct":"edge.func({ connectionString: '...', source: function () {/* SQL */}, db: 'MsSql' });"}],"quickstart":{"code":"const edge = require('edge-js');\n\nconst getProducts = edge.func('sql', function () {/*\n    select top 5 * from Products\n*/});\n\ngetProducts(null, function (error, result) {\n    if (error) throw error;\n    console.log(result);\n});","lang":"javascript","description":"Shows how to query MS SQL via Edge.js with edge-sql, using an inline SQL statement and a callback."},"warnings":[{"fix":"Add nonQuery: true to options if you need to run a select statement as a non-query (e.g., function call).","message":"SQL statements starting with 'select' are executed as ExecuteReaderAsync by default; use nonQuery option to force ExecuteNonQueryAsync for stored procedures without output parameters.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Use the fork: npm install edge-sql (which installs agracio's version).","message":"The original edge-sql by tjanczuk is deprecated; this fork (agracio/edge-sql) is the active version.","severity":"deprecated","affected_versions":"all"},{"fix":"Ensure your Edge.js is running on .NET Core to use PostgreSQL database option.","message":"PostgreSQL support is only available when using .NET Core; not supported on .NET 4.6.2.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Set the environment variable before calling edge.func for the first time, or pass connectionString as an option.","message":"Environment variable EDGE_SQL_CONNECTION_STRING is read only once at initialization. Changing it later has no effect.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Wrap geometry columns with ST_AsText in SELECT and use ST_GeomFromText in INSERT/UPDATE.","message":"Geometry/Geography types in MySQL and PostgreSQL must be converted manually using ST_AsText/ST_GeomFromText; edge-sql does not do automatic conversion.","severity":"gotcha","affected_versions":">=1.0"}],"env_vars":null,"search_vec":"'/clr':28 '4.6.2':35 'access':19 'ado.net':9,81 'applic':17 'automat':50 'base':10 'bridg':74 'c':27,93 'clr':92 'compil':12 'connect':47 'core/netstandard2.0':40 'data':57 'databas':25 'driver':72 'edg':2,5,85,89 'edge-j':88 'edge-sql':1,4 'edge.js':14,87 'edgej':86 'enabl':15 'environ':43 'except':36 'interpret':51 'javascript':71,84 'js':90 'manag':94 'ms':20 'multipl':66 'mysql':22 'net':34,39,77,91 'node.js':16,75 'non':62 'non-queri':61 'option':42 'postgresql':24,37 'prefer':83 'pure':70 'queri':63 'reader':58 'result':67 'return':65 'runtim':46 'scenario':79 'select':55 'set':68 'sql':3,6,11,21,52 'statement':53 'string':48 'support':33 'type':54 'unlik':69 'updat':59 'v1.0.6':31 'variabl':44 'via':26","created_at":"2026-06-05T16:56:07.883483+00:00","updated_at":"2026-06-05T16:56:07.883483+00:00","problems":[{"fix":"Make sure edge-js and edge-sql are both installed: npm install edge-js edge-sql. The compiler is registered by edge-sql when required? Actually, edge-js picks it up from node_modules; if not, try: require('edge-sql');","cause":"The 'sql' compiler is not automatically discovered; edge-sql must be installed and required? Or the module path is wrong.","error":"Error: Cannot find module 'edge-sql'"},{"fix":"Set EDGE_SQL_CONNECTION_STRING environment variable or pass { connectionString: '...' } to edge.func.","cause":"No connection string provided via environment variable or options object.","error":"Error: Connection string is not defined. Provide environment variable EDGE_SQL_CONNECTION_STRING or pass connectionString option."},{"fix":"Ensure the appropriate .NET data provider is installed (e.g., System.Data.SqlClient for MS SQL, Npgsql for PostgreSQL). For PostgreSQL, use .NET Core.","cause":"ADO.NET provider not installed or .NET runtime mismatch (e.g., PostgreSQL on .NET 4.x).","error":"Error: The type initializer for 'Edge.Sql' threw an exception."},{"fix":"Ensure parameters object keys match the parameter names in SQL (case-insensitive for MS SQL).","cause":"Parameterized query expects named parameters but none provided, or parameter mismatch.","error":"Error: Sequence contains no matching element"}],"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/agracio/edge-sql","github":"ssh://git@github.com/agracio/edge-sql","docs":null,"changelog":null,"pypi":null,"npm":"edge-sql","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}}