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({
|
2024-10-08 23:03:42 +02:00
|
|
|
createLogger: () =>
|
2023-07-03 15:33:39 +02:00
|
|
|
{
|
2023-05-02 23:59:06 +02:00
|
|
|
return {
|
2024-10-08 23:03:42 +02:00
|
|
|
debug: console.log,
|
|
|
|
info: console.log,
|
2023-05-02 23:59:06 +02:00
|
|
|
status: console.log,
|
2024-10-08 23:03:42 +02:00
|
|
|
warn: console.log,
|
|
|
|
error: console.error
|
2023-05-02 23:59:06 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}, {
|
2024-10-08 23:03:42 +02:00
|
|
|
load: true,
|
2023-07-13 18:06:07 +02:00
|
|
|
credentials,
|
|
|
|
cluster: {
|
2024-10-08 23:03:42 +02:00
|
|
|
canRetry: true,
|
2023-07-13 18:06:07 +02:00
|
|
|
removeNodeErrorCount: 5,
|
2024-10-08 23:03:42 +02:00
|
|
|
restoreNodeTimeout: 60000,
|
|
|
|
defaultSelector: 'RR'
|
2023-07-13 18:06:07 +02:00
|
|
|
}
|
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();
|