@gdksoftware/mysql
TypeScript icon, indicating that this package has built-in type declarations

1.3.2 • Public • Published

@gdksoftware/mysql

This is a wrapper for the mysql package. It makes it easier to connect and execute queries. It supports both common Javascript and TypeScript as well. One of the advantages is that you don't have to think about ending the connection with the database. The query command will do this automatically for you.

Installation

npm install @gdksoftware/mysql
yarn add @gdksoftware/mysql
bower install @gdksoftware/mysql --save

Usage

Javascript

const MySQL = require('@gdksoftware/mysql');

let db = new MySQL({
    host: 'localhost',
    user: 'root',
    password: 'pwd',
    port: '3306',
    database: 'mydb'
})


// Query without parameters
db.query('SELECT * FROM user').then((rows) => {
  
  // Do something with the given rows
}, (err) => {

  // Handle the exception
})

TypeScript

The import differs For TypeScript, but you can use it like the common Javascript example.

import MySQL from '@gdksoftware/mysql';

// Query with parameters
let userid = 100
db.query('SELECT * FROM user WHERE id = ?', [userid]).then((rows) => {
  
  // Do something with the given rows
}, (err) => {

  // Handle the exception
})

Package built by GDK Software NL / GDK Software UK

Readme

Keywords

Package Sidebar

Install

npm i @gdksoftware/mysql

Weekly Downloads

4

Version

1.3.2

License

ISC

Unpacked Size

7.5 kB

Total Files

15

Last publish

Collaborators

  • pquist
  • rvorthoren
  • reinierstam
  • cdekraker
  • cmgeuze