node-jdbc-driver
JDBC API Wrapper for node.js, The API offers methods to open and close database connections, issue query and update statements, and also retrieve information -- such as table and column structure -- in a database-independent way.
Latest Version
Installation
- Release:
npm i --save node-jdbc-driver
Usage
Some mininal examples are given below.
Initialize
const { default: JdbcDriver, ConnectionType } = require("node-jdbc-driver")
import JdbcDriver, { ConnectionType } from 'node-jdbc-driver'
const host = '<host>';
const port = '<port>';
const database = '<database_name>';
const username = '<username>';
const password = '<password>';
ConnectionType.hive
ConnectionType.postgreSql
const jdbc = new JdbcDriver(ConnectionType.postgreSql, {host, port, database, username, password})
const version = jdbc.get_version()
const total = await jdbc.count('<table_name>')
const row = await jdbc.find('<table_name>', '<where_clouse>')
const rows = await jdbc.findAll('<table_name>')
const results = await jdbc.sql('<sql_query>')
const columns = await jdbc.get_columns('<table_name>')
const tblproperties = await jdbc.get_table_properties('<table_name>')