Skip to content

Release Oracle client #65

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

Merged
merged 4 commits into from
Jan 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @observablehq/database-proxy

The database proxy is a simple Node.js webserver that accepts secure requests from your Observable notebooks, and proxies queries to a PostgreSQL or MySQL database — one that is not necessarily exposed to the web. You can use the database proxy to securely connect to databases on your local computer, on an intranet or within a VPN.
The database proxy is a simple Node.js webserver that accepts secure requests from your Observable notebooks, and proxies queries to a PostgreSQL, MySQL, Snowflake, SQL Server, Databricks or Oracle database — one that is not necessarily exposed to the web. You can use the database proxy to securely connect to databases on your local computer, on an intranet or within a VPN.

## Installation

@@ -11,6 +11,21 @@ Install the database proxy locally or globally with `npm` or `yarn`:
yarn global add @observablehq/database-proxy
```

### Installing for Oracle Databases

To use the Oracle database client, you will also need to install the `oracledb` npm library with `npm` or `yarn`:
```
npm install -g oracledb
yarn global add oracldeb
```
#### Architecture
Node-oracledb is an [add-on](https://nodejs.org/api/addons.html) available as C source code. Pre-built binaries are available as a convenience for common architectures (Windows 64-bit, Linux x86_64, and macOS (Intel x86)). For other architectures (i.e `macOS (ARM64)`), you will need to build from the source code as described [here](https://node-oracledb.readthedocs.io/en/latest/user_guide/installation.html#quick-start-node-oracledb-installation).

#### Oracle Client Library
One of the Oracle Client libraries version 21, 19, 18, 12, or 11.2 needs to be installed in your operating system library search path such as `PATH` on Windows or `LD_LIBRARY_PATH` on Linux. On macOS link the libraries to `/usr/local/lib`.

For more information see [node-oracldb](https://node-oracledb.readthedocs.io/en/latest/user_guide/installation.html) documentation.

## Running the database proxy

Usage: `observable-database-proxy <command> <name> [options]`
55 changes: 35 additions & 20 deletions lib/commands.js
Original file line number Diff line number Diff line change
@@ -23,6 +23,8 @@ export async function add(argv, reset = false) {
let token;
let server_host;
let path;
let username;
let password;

if (config && config[name] && !reset)
exit(`A database proxy for "${name}" already exists`);
@@ -59,32 +61,45 @@ export async function add(argv, reset = false) {

// DB credentials
if (!reset) {
// Databricks credentials
if (decoded.type === "databricks") {
token = await question("Databricks token: ");
server_host = await question("Databricks server host: ");
path = await question("Databricks path: ");
} else {
url = await question(
"PostgreSQL, MySQL, or Snowflake Database URL (including username and password): "
);
switch (decoded.type) {
case "databricks":
token = await question("Databricks token: ");
server_host = await question("Databricks server host: ");
path = await question("Databricks path: ");
break;
case "oracle":
username = await question("Username: ");
password = await question("Password: ");
url = await question("Connection String: ");
break;
default:
url = await question(
"PostgreSQL, MySQL, or Snowflake Database URL (including username and password): "
);
}
}

rl.close();

if (!config) config = {};
if (decoded.type === "databricks") {
config[name] = {
name,
secret,
token,
server_host,
path,
};
} else {
config[name] = {name, secret, url};
}
config[name] =
decoded.type === "databricks"
? {
name,
secret,
token,
server_host,
path,
}
: decoded.type === "oracle"
? {
name,
secret,
username,
password,
url,
}
: {name, secret, url};

writeConfig(config);