Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

highsql

Package Overview
Dependencies
Maintainers
0
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

highsql

High level MySQL utility

  • 1.2.0
  • npm
  • Socket score

Version published
Weekly downloads
10
Maintainers
0
Weekly downloads
 
Created
Source

MySQL Connection Manager

npm version License

A simple and secure Node.js module for managing MySQL database connections.

Features

  • Promise-based: Utilizes mysql2/promise for a modern asynchronous interface.
  • Connection Pooling: Efficiently manages multiple connections for optimal performance.
  • Prepared Statements: Prioritizes security against SQL injection attacks.
  • Flexible Queries: Allows executing arbitrary SQL statements (with caution).

Installation

npm install highsql

Usage

import Connection from 'highsql';

async function main() {
const conn = new Connection('your_host', 'your_user', 'your_password', 'your_database');

    // Example: Select data
    const rows = await conn.select('users', 'id, name', 'id = ?', [1]);

    // Example: Insert data (use prepared statements!)
    await conn.insert('users', { name: 'Alice', email: 'alice@example.com' });

    // Example: Update data
    await conn.update('users', { email: 'alice@highsql.com' }, 'id = ?', [1]);

    // Example: Delete data
    await conn.delete('users', 'id = ?', [1]);
}

main();

Functions

FunctionDescriptionParametersReturns
select(table, columns, where?, params?)Executes a SELECT query.table, columns, optional where condition, optional array of params for prepared statementsPromise<RowDataPacket[]>
insert(table, values)Executes an INSERT query.table, an object of values to insertPromise<ResultSetHeader>
update(table, values, where, params?)Executes an UPDATE query.table, an object of values to update, where condition, optional array of paramsPromise<ResultSetHeader>
delete(table, where, params?)Executes a DELETE query.table, where condition, optional array of paramsPromise<ResultSetHeader>
query(sql, values?)Executes an arbitrary SQL statement (use with caution!).sql statement, optional array of values for prepared statements`Promise<ResultSetHeader

License

This project is licensed under the MIT License - see the LICENSE file for details.

FAQs

Package last updated on 07 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc