Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

oracledb

Package Overview
Dependencies
Maintainers
4
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oracledb

A Node.js module for Oracle Database access from JavaScript and TypeScript

  • 6.7.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
237K
increased by6.98%
Maintainers
4
Weekly downloads
 
Created

What is oracledb?

The oracledb npm package is a Node.js driver for Oracle Database, providing a way to connect to Oracle databases, execute SQL queries, and manage database transactions. It supports various features such as connection pooling, data types, and advanced Oracle Database features.

What are oracledb's main functionalities?

Connecting to Oracle Database

This code demonstrates how to establish a connection to an Oracle Database using the oracledb package. It includes error handling and ensures the connection is closed after use.

const oracledb = require('oracledb');

async function run() {
  let connection;

  try {
    connection = await oracledb.getConnection({
      user: 'your_username',
      password: 'your_password',
      connectString: 'localhost/XEPDB1'
    });
    console.log('Connection was successful!');
  } catch (err) {
    console.error(err);
  } finally {
    if (connection) {
      try {
        await connection.close();
      } catch (err) {
        console.error(err);
      }
    }
  }
}

run();

Executing SQL Queries

This code sample shows how to execute a SQL query using the oracledb package. It retrieves rows from the 'employees' table where the department_id is 101.

const oracledb = require('oracledb');

async function run() {
  let connection;

  try {
    connection = await oracledb.getConnection({
      user: 'your_username',
      password: 'your_password',
      connectString: 'localhost/XEPDB1'
    });

    const result = await connection.execute(
      `SELECT * FROM employees WHERE department_id = :id`,
      [101] // bind value for :id
    );

    console.log(result.rows);
  } catch (err) {
    console.error(err);
  } finally {
    if (connection) {
      try {
        await connection.close();
      } catch (err) {
        console.error(err);
      }
    }
  }
}

run();

Using Connection Pooling

This code demonstrates how to use connection pooling with the oracledb package. It creates a pool of connections, retrieves a connection from the pool, executes a query, and then closes the connection and the pool.

const oracledb = require('oracledb');

async function run() {
  let pool;

  try {
    pool = await oracledb.createPool({
      user: 'your_username',
      password: 'your_password',
      connectString: 'localhost/XEPDB1',
      poolMin: 2,
      poolMax: 10,
      poolIncrement: 1
    });

    const connection = await pool.getConnection();
    const result = await connection.execute(`SELECT * FROM employees`);
    console.log(result.rows);
    await connection.close();
  } catch (err) {
    console.error(err);
  } finally {
    if (pool) {
      try {
        await pool.close(0);
      } catch (err) {
        console.error(err);
      }
    }
  }
}

run();

Other packages similar to oracledb

Keywords

FAQs

Package last updated on 18 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc