1.2.1 • Published 1 year ago

@shippify/db-manager v1.2.1

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
1 year ago

DBManager

This a library to manage better the database connections

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Installing

This is a Node.js module available through to include in your package.json file.

....
"dependencies": {
    "@shippify/db-manager": "^1.0.0",
}
....

Installation is done using the npm install command:

npm install

Environment variables

You need to set up these variables to use this library:

To use MySQL

#-------------------------
#       general purpose
#-------------------------
MYSQL_QUERY_LOGS=1 #Optional, By default is 1
#-------------------------
#         master
#-------------------------
MYSQL_HOST=localhost
MYSQL_USER=writer
MYSQL_PASSWORD=writerpassword
MYSQL_DATABASE=shippify-db
MYSQL_NO_CONNECTIONS=1 #Optional
#-------------------------
#         slave
#-------------------------
MYSQL_SLAVE_HOST=localhost
MYSQL_SLAVE_USER=writer
MYSQL_SLAVE_PASSWORD=writerpassword
MYSQL_SLAVE_DATABASE=shippify-db
MYSQL_SLAVE_NO_CONNECTIONS=1 #Optional

To use Redis

REDIS_HOST=localhost REDIS_PASSWORD=redispassword

To use Kafka

KAFKA_HOST=localhost KAFKA_USER= KAFKA_PASSWORD= KAFKA_MECHANISM=

How to use this library? Look this example for MySQL.

const DBManager = require('db-manager');

// MySQL

const mysql = new DBManager.MySQL();

const query = SELECT * FROM task LIMIT 1000 mysql.querySlave(query, (error, result)=>{ if(error) console.log('ERROR:',error); console.log('RESULT:',result); })

Look the examples directory, If you need more examples with Redis
[here](https://gitlab.com/shippify/db-connector/blob/master/examples/index.js)


## Versioning

We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags). 

## Authors

* **Leonardo Larrea** - *Lead Developer*

See also the list of [contributors](https://gitlab.com/shippify/db-connector/graphs/master) who participated in this project.