Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// ----------------------------------------------------------------------------
// Create the connection to database
const dbConfig = {
host: "localhost",
port: 57615,
user: "root",
password: "12345",
database: "TestDb"
};
const connection = somesqldb.createConnection(dbConfig);
// Static info describing the database
const dbInfo = {
name: dbConfig.database,
vendor: Sdk.DatabaseVendor.MARIADB,
host: dbConfig.host,
port: dbConfig.port
};
// Issue a traced SQL database request
function tracedSqlDatabaseRequest(sql, clientCb) {
// create a SQL database tracer
const tracer = Api.traceSQLDatabaseRequest(dbInfo, {
statement: sql
});
// start tracer, calls connection.query(sql, cb) with connection set as this in query()
tracer.startWithContext(connection.query, connection, sql, (err, results, fields) => {
if (err) {
// set the error on the tracer
tracer.error(err);