Skip to content

A mysql client tools for nodejs and want to look for a girlfriend...

License

Notifications You must be signed in to change notification settings

bluedapp/ai-mysql-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ai-mysql-client

npm version

A mysql client tools for nodejs and want to look for a girlfriend...

Installation

$ npm i ai-mysql-client

Example

import createMySQLClient from 'ai-mysql-client'

// https://www.npmjs.com/package/@blued-core/qconf
qconf.flag: isLocalPro ? 'production' : '',

const mysqlClient = key => {
  return createMySQLClient({
    key,
    option: qconf,
    connections: 20,
    time: 60,
  })()

  // or

  return createMySQLClient({
    master: ['127.0.0.1:3306'],
    slave: ['127.0.0.1:3306', '127.0.0.1:3306', '127.0.0.1:3306'],
    username: 'root',
    password: 'your@123',
    database: 'test',
    time: 60,
    connections: 20,
  }, key)()
}

async function getTest() {
  const defaultMySQL = mysqlClient('default')

  const sql = 'SELECT * FROM test_user LIMIT 0,10'
  const res = await defaultMySQL.query(sql).catch(err => {
    console.error(err, { tips: 'query error' })
  })

  console.log(res)

  return res
}

Options

// options
interface Config {
  key?: string
  option: any
  connections?: number
  time?: number
}

// or

interface MySQL {
  master: Array<string>
  slave: Array<string>
  username: string
  password: string
  database: string
  connections?: number
  time?: number
}

License

MIT License

About

A mysql client tools for nodejs and want to look for a girlfriend...

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published