1.0.6 • Published 9 months ago

sqlmanager v1.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

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();
1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago