New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

sqlmanager

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sqlmanager

A powerful utility for managing SQL database operations.

latest
npmnpm
Version
1.0.6
Version published
Maintainers
1
Created
Source

SQLManager

A powerful utility for managing SQL database operations.

Description

SQLManager is a module designed to simplify and streamline your interactions with SQL databases. Whether you're using SQLite, MySQL, or any other SQL variant, SQLManager makes tasks like table creation, query execution, and transaction handling easier than ever.

Usage

To make use of the SQLManager module, first import it:

const SQLManager = require("sqlmanager");

You can then instantiate it with a configuration object detailing your database parameters.

From there, leverage the methods provided by the module to interact with your database.

Arguments

  • type: The type of SQL database you're using (e.g., "sqlite", "mysql").
  • path: The path to your SQLite database file (Required if you're using SQLite).
  • host: The host of your MySQL server (Required if you're using MySQL).
  • port: The port of your MySQL server (Required if you're using MySQL).
  • username: The username for your MySQL database (Required if you're using MySQL).
  • password: The password for your MySQL database (Required if you're using MySQL).
  • database: The name of your MySQL database (Required if you're using MySQL).

Examples

SQLite Example:

const SQLManager = require("sqlmanager");

async function main() {
  const databaseConfig = {
    type: "sqlite",
    path: "./database.sqlite",
  };

  const sqlManager = new SQLManager(databaseConfig);
  
  await sqlManager.createTable((table) => {
    table.setName("users").addColumn((column) => {
      column.setName("id").setType("INT AUTO_INCREMENT PRIMARY KEY");
    })
    .addColumn((column) => {
      column.setName("user").setType("VARCHAR(255) NOT NULL");
    })
    .addColumn((column) => {
      column.setName("password").setType("VARCHAR(255) NOT NULL");
  });
  });
}

main();

MySQL Example:

const SQLManager = require("sqlmanager");

async function main() {
  const databaseConfig = {
    type: "mysql",
    host: "localhost",
    port: 3306,
    username: "root",
    password: "password",
    database: "test"
  };

  const sqlManager = new SQLManager(databaseConfig);
  
  await sqlManager.createTable((table) => {
    table.setName("users").addColumn((column) => {
      column.setName("id").setType("INT AUTO_INCREMENT PRIMARY KEY");
    })
    .addColumn((column) => {
      column.setName("user").setType("VARCHAR(255) NOT NULL");
    })
    .addColumn((column) => {
      column.setName("password").setType("VARCHAR(255) NOT NULL");
  });
  });
}

main();

Keywords

sql

FAQs

Package last updated on 10 Aug 2023

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