oracle / node-oracledb

Oracle Database driver for Node.js maintained by Oracle Corp.
http://oracle.github.io/node-oracledb/
Other
2.25k stars 1.07k forks source link

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

Closed hogod closed 2 years ago

hogod commented 2 years ago

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.

cjbj commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

sosoba commented 2 years ago

@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 commented 2 years ago

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 commented 2 years ago

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

rmainwork commented 2 years ago

@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 commented 2 years ago

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

rmainwork commented 2 years ago

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 commented 2 years ago

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

cjbj commented 2 years ago

@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 commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

@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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 1 year ago

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 commented 1 year ago

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