2023-07-13 18:06:07 +02:00
|
|
|
process.env.NODE_ENV = 'development';
|
2023-05-02 23:59:06 +02:00
|
|
|
import { readFileSync } from 'fs';
|
|
|
|
import { MariaDB } from '../build/esm/index.js';
|
|
|
|
|
2023-07-13 18:06:07 +02:00
|
|
|
const credentials = JSON.parse(readFileSync('../credentials.json', { encoding: 'utf-8' }));
|
2023-05-02 23:59:06 +02:00
|
|
|
|
|
|
|
const maria = new MariaDB({
|
2023-07-03 15:33:39 +02:00
|
|
|
createLogger: () =>
|
|
|
|
{
|
2023-05-02 23:59:06 +02:00
|
|
|
return {
|
|
|
|
debug: console.log,
|
|
|
|
info: console.log,
|
|
|
|
status: console.log,
|
|
|
|
warn: console.log,
|
|
|
|
error: console.error
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
load: true,
|
2023-07-13 18:06:07 +02:00
|
|
|
credentials,
|
|
|
|
cluster: {
|
|
|
|
canRetry: true,
|
|
|
|
removeNodeErrorCount: 5,
|
|
|
|
restoreNodeTimeout: 60000,
|
|
|
|
defaultSelector: 'RR'
|
|
|
|
}
|
2023-05-02 23:59:06 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
await maria.init();
|
|
|
|
|
2023-07-13 18:06:07 +02:00
|
|
|
// await maria.query('INSERT INTO `test` (`dingle`, `bingle`) VALUES ?', [[ 1, 2 ], [ 3, 4 ], [ 5, 6 ]]);
|
2023-05-02 23:59:06 +02:00
|
|
|
|
|
|
|
await maria.close();
|