mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 13:24:24 +00:00
add more mysql stuff
This commit is contained in:
@@ -1,15 +1,40 @@
|
||||
const mysql = require( 'promise-mysql' );
|
||||
/*
|
||||
* libreevent - mysqldb.js
|
||||
*
|
||||
* Created by Janis Hutz 07/12/2023, Licensed under the GPL V3 License
|
||||
* https://janishutz.com, development@janishutz.com
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
const mysql = require( 'mysql' );
|
||||
const db = require( './db.js' );
|
||||
|
||||
// If the connection does not work for you, you will need to add your ip
|
||||
// to the whitelist of the database
|
||||
|
||||
class SQLDB {
|
||||
constructor () {
|
||||
this.sqlconnection = mysql.createConnection( {
|
||||
host: 'janishutz.com',
|
||||
port: '3306',
|
||||
user: 'janishut_libreeventTest',
|
||||
password: '^PVgj&xkaQKmMDCgz&2^aCaYxc7nCS#*%7%',
|
||||
connectionLimit: 200
|
||||
this.sqlConnection = mysql.createConnection( db.getJSONDataSync( '/config/db.config.secret.json' ) );
|
||||
}
|
||||
|
||||
connect () {
|
||||
this.sqlConnection.connect( function( err ) {
|
||||
if ( err ) {
|
||||
console.error( 'error connecting: ' + err.stack );
|
||||
return;
|
||||
}
|
||||
return 'connection';
|
||||
} );
|
||||
}
|
||||
|
||||
disconnect () {
|
||||
this.sqlConnection.end();
|
||||
}
|
||||
|
||||
async setupDB () {
|
||||
this.sqlConnection.query( '' );
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SQLDB;
|
||||
Reference in New Issue
Block a user