node-oracledb thin 模式试用

node-oracledb client 已经支持thin 模式了,npm 包小了很多,以下是一个测试

环境准备

基于容器部署的oracle

  • docker-compose
version: '3'
services:
   db:
      image: gvenzl/oracle-xe:21.3.0-slim
      ports:
         - "1521:1521"
      environment:
       - ORACLE_PASSWORD=Ccda5662E
       - APP_USER=dalong
       - APP_USER_PASSWORD=Ccda5662E

node-oracledb 代码测试

  • app.js
const oracledb = require('oracledb');
 
oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT;
 
const mypw = "Ccda5662E"  // set mypw to the hr schema password
 
async function run() {
 
    const connection = await oracledb.getConnection ({
        user          : "system",
        password      : mypw,
        connectString : "localhost/XEPDB1"
    });
 
    const result = await connection.execute(
        `select 'dalong' as demo from dual`
    );
 
    console.log(result.rows);
    await connection.close();
}
 
run();
  • 效果

 

说明

从使用上发现还会很方便的,包括安装以及代码集成

参考资料

https://github.com/oracle/node-oracledb
https://node-oracledb.readthedocs.io/en/latest/user_guide/introduction.html#getting-started-with-node-oracledb

posted on   荣锋亮  阅读(133)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2022-10-08 dremio 23.0 版本发布
2022-10-08 openjdk 11 以及8 项目构建退休建议选择其他构建源
2020-10-08 nessie 安装&&简单试用
2020-10-08 nessie 类似git 管理数据湖
2020-10-08 一些不错的开源大数据虚拟数据sql 查询引擎
2020-10-08 What Is a Data Lake Engine?
2019-10-08 typedi 强大的javascript以及typescript 依赖注入框架

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示