Skip to content

Commit 01d4e82

Browse files
author
Sylvestre
authoredJan 19, 2023
Oracle client (#65)
* Update README.md * Update README.md * Update README.md * handle oracle credentials
1 parent c4737dd commit 01d4e82

File tree

2 files changed

+51
-21
lines changed

2 files changed

+51
-21
lines changed
 

‎README.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# @observablehq/database-proxy
22

3-
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.
3+
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.
44

55
## Installation
66

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

14+
### Installing for Oracle Databases
15+
16+
To use the Oracle database client, you will also need to install the `oracledb` npm library with `npm` or `yarn`:
17+
```
18+
npm install -g oracledb
19+
yarn global add oracldeb
20+
```
21+
#### Architecture
22+
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).
23+
24+
#### Oracle Client Library
25+
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`.
26+
27+
For more information see [node-oracldb](https://node-oracledb.readthedocs.io/en/latest/user_guide/installation.html) documentation.
28+
1429
## Running the database proxy
1530

1631
Usage: `observable-database-proxy <command> <name> [options]`

‎lib/commands.js

+35-20
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export async function add(argv, reset = false) {
2323
let token;
2424
let server_host;
2525
let path;
26+
let username;
27+
let password;
2628

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

6062
// DB credentials
6163
if (!reset) {
62-
// Databricks credentials
63-
if (decoded.type === "databricks") {
64-
token = await question("Databricks token: ");
65-
server_host = await question("Databricks server host: ");
66-
path = await question("Databricks path: ");
67-
} else {
68-
url = await question(
69-
"PostgreSQL, MySQL, or Snowflake Database URL (including username and password): "
70-
);
64+
switch (decoded.type) {
65+
case "databricks":
66+
token = await question("Databricks token: ");
67+
server_host = await question("Databricks server host: ");
68+
path = await question("Databricks path: ");
69+
break;
70+
case "oracle":
71+
username = await question("Username: ");
72+
password = await question("Password: ");
73+
url = await question("Connection String: ");
74+
break;
75+
default:
76+
url = await question(
77+
"PostgreSQL, MySQL, or Snowflake Database URL (including username and password): "
78+
);
7179
}
7280
}
7381

7482
rl.close();
7583

7684
if (!config) config = {};
77-
if (decoded.type === "databricks") {
78-
config[name] = {
79-
name,
80-
secret,
81-
token,
82-
server_host,
83-
path,
84-
};
85-
} else {
86-
config[name] = {name, secret, url};
87-
}
85+
config[name] =
86+
decoded.type === "databricks"
87+
? {
88+
name,
89+
secret,
90+
token,
91+
server_host,
92+
path,
93+
}
94+
: decoded.type === "oracle"
95+
? {
96+
name,
97+
secret,
98+
username,
99+
password,
100+
url,
101+
}
102+
: {name, secret, url};
88103

89104
writeConfig(config);
90105

0 commit comments

Comments
 (0)
Please sign in to comment.