Skip to content

Is it possible to use node-oracledb in client alone "clean"? #1497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hogod opened this issue May 20, 2022 · 22 comments
Closed

Is it possible to use node-oracledb in client alone "clean"? #1497

hogod opened this issue May 20, 2022 · 22 comments
Labels

Comments

@hogod
Copy link

hogod commented May 20, 2022

hello,

We are currently planning a project that requires direct connection to "OracleDB" from a node client.

However, we encountered numerous problems in Addon and Node-gyp during pilot application development before enter project.

In addition, it was confirmed that "Node-OracleDB" also adopts the method of converting C++ and C to Node-Gyp, not pure JavaScript.

And, like other libraries using Node-Gyp, "OracleDB" also returned numerous errors and problems depending on the environment and dependencies.

The case is identical to the many issues that can be found by searching "React", "Electron", "Webpack", "Node-Gyp".

Our question is:

  1. I would like to know if there is a guideline for using "node-oracledb" in Windows and Linux environment clients and browsers.

  2. Connectors developed with pure Javascript such as Mysql and Postgresql do not cause the following problems. I would like to know if Oracle has any plans to provide a Connector developed in pure Javascript.

  3. As a developer in the Oracle ecosystem, I would like to hear your advice on whether it is appropriate to use "node-oracledb" in a client application project to directly connect to db, that needs to be deployed in a Window, Linux environment, or Browser environment.

Thanks for reading. I am waiting for your reply.

@hogod hogod added the question label May 20, 2022
@cjbj
Copy link
Member

cjbj commented May 20, 2022

I wouldn't say that node-oracledb converts to Node-Gyp. I would say it is C code that uses Node-API.

Node-oracledb can be used on the client - but you need Node.js. You can't embed it in a browser. In general it would be better positioned as a mid-tier so you can make good use of connection pooling. Browsers can make REST or GraphQL calls to a Node.js application that uses node-oracledb, or you can skip using Node.js altogether and just call from the browser to Oracle's ORDS.

We are close to releasing a 'Thin' driver for Python and are starting to explore how we can do something similar for Node.js. Note I said Node.js, not JavaScript since we will probably need to make use of some Node.js libraries. But this is yet to be explored.

I hope this explains it for you.

@sosoba
Copy link

sosoba commented May 26, 2022

We are close to releasing a 'Thin' driver for Python

Very nice news. I always thought that Oracle would never release the client code sources.

I said Node.js, not JavaScript since we will probably need to make use of some Node.js libraries. But this is yet to be explored.

I propose to go towards the WebStream standards at the network socket interface and database BLOB implementation. This will make it easier to use on environments other than Node.

@cjbj
Copy link
Member

cjbj commented May 26, 2022

@sosoba
Copy link

sosoba commented May 27, 2022

@sosoba the Python Thin driver is available: https://medium.com/@cjones-oracle/open-source-python-thin-driver-for-oracle-database-e82aac7ecf5a

Yes, I was already browsing the source code with curiosity. Does the thin protocol have public documentation?

@cjbj
Copy link
Member

cjbj commented May 27, 2022

There is no public doc on the protocol. We'll have a high level blog soon, but it won't go into details - that would be a big project.

@cjbj
Copy link
Member

cjbj commented Jun 2, 2022

Closing. No response from filer so I assume the question was answered.

@rmainwork
Copy link

@sosoba the Python Thin driver is available: https://medium.com/@cjones-oracle/open-source-python-thin-driver-for-oracle-database-e82aac7ecf5a

Very cool - are there any plans for a node thin driver?

@anthony-tuininga
Copy link
Member

That is being explored but in the early stages yet. @cjbj will let you know when that is closer to becoming reality. :-)

@rmainwork
Copy link

Ah cool. That sounds great!

For context: my interest in this stems from an app we have that needs to talk to Oracle only in prod and node-oracledb looking for oracle isntant client and other client libraries as a post-install hook makes the setup of a dev environment a little tricky/finicky.

My understanding is that:

  1. There is currently no way to install node-oracledb without the client libraries installed(even though the code that uses node-oracledb won't actually run in dev).
  2. A thin driver would solve this problem by stubbing out/replacing or somehow removing the dependency on pre-installed client libraries.

This is perhaps a little off-topic for this issue, but are these assumptions/thoughts accurate?

@anthony-tuininga
Copy link
Member

Yes, those assumptions/thoughts are accurate. :-)

@cjbj
Copy link
Member

cjbj commented Jun 8, 2022

@rmainseas Point 1 isn't true if you are using node-oracledb from npm. The Oracle Client libraries are only loaded at runtime by node-oracledb. In fact, they are loaded at point of first connection, so you can even do a require("oracledb") when client libraries are not available.

However if you installed node-oracledb via some package manager e.g. yum, then the package dependencies may force Instant Client to be installed.

@sosoba
Copy link

sosoba commented Jun 13, 2022

That is being explored but in the early stages yet. @cjbj will let you know when that is closer to becoming reality. :-)

Even if it's a POC that just connects to database and can only do "SELECT SYSDATE FROM DUAL" would be worth seeing.

@cjbj
Copy link
Member

cjbj commented Jun 15, 2022

@sosoba we do plan to share a pre-release branch, but not quite yet. I need to do some paperwork for approvals, and the code needs some work first.

@rmainwork
Copy link

@rmainseas Point 1 isn't true if you are using node-oracledb from npm. The Oracle Client libraries are only loaded at runtime by node-oracledb. In fact, they are loaded at point of first connection, so you can even do a require("oracledb") when client libraries are not available.

However if you installed node-oracledb via some package manager e.g. yum, then the package dependencies may force Instant Client to be installed.

I'll have to double check on this, but my recollection is that the project won't even install without the client libraries....

@cjbj
Copy link
Member

cjbj commented Jun 16, 2022

Maybe you recall the Linux RPMs?

If you google for DPI-1047, you'll find plenty of people with a runtime error saying the libraries can't be loaded. All the library loading code is performed at runtime: https://github.com/oracle/odpi/blob/v4.4.1/src/dpiOci.c#L52-L60

@rmainwork
Copy link

So, this was on a Debian based system, so likely not the RPMs. In addition, the version of node-oracledb the project uses is quite old (2.3.0) so it's possible that the behavior is different to latest

@raymclee
Copy link

I wouldn't say that node-oracledb converts to Node-Gyp. I would say it is C code that uses Node-API.

Node-oracledb can be used on the client - but you need Node.js. You can't embed it in a browser. In general it would be better positioned as a mid-tier so you can make good use of connection pooling. Browsers can make REST or GraphQL calls to a Node.js application that uses node-oracledb, or you can skip using Node.js altogether and just call from the browser to Oracle's ORDS.

We are close to releasing a 'Thin' driver for Python and are starting to explore how we can do something similar for Node.js. Note I said Node.js, not JavaScript since we will probably need to make use of some Node.js libraries. But this is yet to be explored.

I hope this explains it for you.

Hi cjbj, Is there a performance different between node-oracledb and oracle ords?

@sosoba
Copy link

sosoba commented Jul 26, 2022

Is there a performance different between node-oracledb and oracle ords?

ORDS is a Java web application. JVM + servlet container + app will need an additional 1GB of RAM. Of course, each database query will take logner time for the data serialization and the reaction of the second process.

But in most real applications, it will not matter because the dominant feature is the time the operation is performed by the database, not the transmission to the client.

@MasterOdin
Copy link

MasterOdin commented Jul 27, 2022

Having a thin client in node would be absolutely awesome and simplify my life tremendously as having to include the instant client stuff with our electron app easily outweighs the rest of our code in size.

@rmainseas Point 1 isn't true if you are using node-oracledb from npm. The Oracle Client libraries are only loaded at runtime by node-oracledb. In fact, they are loaded at point of first connection, so you can even do a require("oracledb") when client libraries are not available.

Unless you're on a system that doesn't have prebuilt binaries available like M1...

yarn add oracledb
yarn add v1.22.17
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
error /Users/mpeveler/code/oracle-tmp/node_modules/oracledb: Command failed.
Exit code: 87
Command: node package/install.js
Arguments:
Directory: /Users/mpeveler/code/oracle-tmp/node_modules/oracledb
Output:
oracledb ERR! NJS-067: a pre-built node-oracledb binary was not found for darwin arm64
oracledb ERR! Try compiling node-oracledb source code using https://oracle.github.io/node-oracledb/INSTALL.html#github
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

@cjbj
Copy link
Member

cjbj commented Aug 12, 2022

I will close this as it has run its course. The team is working hard on the Thin driver mode project.

Side note: You should be able to use the current node-oracledb on M1 by using Rosetta. You need to use/invoke the Intel Node.js binary - and compile the driver yourselves.

@liudonghua123
Copy link

Thin mode of python-oracledb is available, see https://github.com/oracle/python-oracledb#dependencies-and-interoperability. Hope thin mode of node-oracledb could arrive soon.

@cjbj
Copy link
Member

cjbj commented May 26, 2023

For future readers, node-oracledb 6.0 has been released. It has a Thin mode and can be used without Instant Client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants