You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

mysql-json-formatter

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mysql-json-formatter

This package is used to edit MySQL queries containing 'JOIN' in JSON format

1.2.1
latest
npmnpm
Version published
Weekly downloads
23
Maintainers
0
Weekly downloads
 
Created
Source

mysql-json-formatter

This package is used to edit MySQL queries containing 'JOIN' in JSON format

Declaretions

.env

DB_NAME = 'dbname'
FSQL_HOST = 'host_ip'
FSQL_USER = 'username' //! I recommend that you type the root user
FSQL_PASSWORD = 'password'

db.js

const mysql = require('mysql');
require('dotenv').config();
const conn = mysql.createConnection({
    host:process.env.FSQL_HOST,
    user:process.env.FSQL_USER,
    password:process.env.FSQL_PASSWORD,
    database:process.env.DB_NAME
})


conn.connect(()=>{
    console.log('Connected to MySQL');
})


module.exports = conn;

Usage / Examples

const fquery = require('mysql-json-formatter');
const db = require('./db');

async function mysqlJsonFormat() {

  await fquery(`
  SELECT * FROM stocks 
  LEFT JOIN patterns pt ON pt.id = stocks.pattern_id 
  LEFT JOIN machines mc ON mc.id = stocks.machine_id
  `,db);

}

  await fquery(`
  SELECT * FROM stocks 
  LEFT JOIN patterns pt ON pt.id = stocks.pattern_id 
  LEFT JOIN machines mc ON mc.id = stocks.machine_id
  WHERE id = ?
  `,db,['2']);

FAQs

Package last updated on 01 Aug 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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.