Skip to content

Commit a6f8e26

Browse files
committed
Added examples for Python/cx_Oracle and Node.js/node-oracledb
TimesTen now supports connectivity for Python (via cx_Oracle) and Node.js (via node-oracledb)
1 parent 7b5fb47 commit a6f8e26

File tree

15 files changed

+2733
-0
lines changed

15 files changed

+2733
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This repository stores a variety of examples demonstrating how to use the Oracle
66
| :-------------------------- | :---------------------------------------------- |
77
| [quickstart](./quickstart) | Classic QuickStart and Scaleout samples. See the README file in that directory for more information. |
88
| [cloud](./cloud) | Scripts to simplify deployment of TimesTen Scaleout in Oracle Cloud. See the README file in that directory for more information. |
9+
| [languages](./languages) | Open Source language support samples (Python and Node.js) |
910

1011

1112
## More information

languages/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# TimesTen Open Source Languages Samples
2+
3+
This folder contains various examples that illustrate database connection and operations using 3rd party open source languages against the TimesTen database.
4+
5+
| Repository/Folder name | Description |
6+
| :-------------------------- | :---------------------------------------------- |
7+
| [nodejs](./nodejs) | Node.js Sample programs |
8+
| [python](./python) | Python sample programs. |
9+
10+
## More information
11+
You can find more information about the Oracle TimesTen In-Memory Database on our [Product Portal](https://www.oracle.com/database/technologies/related/timesten.html)
12+
13+
## Documentation
14+
You can find the online documentation for Oracle TimesTen In-Memory Database in the [Documentation Library](https://docs.oracle.com/database/timesten-18.1/).

languages/THIRD_PARTY_LICENSES.txt

Lines changed: 1467 additions & 0 deletions
Large diffs are not rendered by default.

languages/nodejs/AccessControl.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* Licensed under the Universal Permissive License v 1.0 as shown
5+
* at http://oss.oracle.com/licenses/upl
6+
*
7+
* DESCRIPTION
8+
* Provides functions to get the usernames and passwords
9+
* for the samples.
10+
*/
11+
12+
function parseArgs(){
13+
args = process.argv.slice(2);
14+
let opts = {};
15+
for(var i = 0; i < args.length; i+=2){
16+
opts[args[i]] = args[i+1];
17+
}
18+
return opts;
19+
}
20+
21+
function usage(scriptName){
22+
return `
23+
Usage: node ${scriptName} -u <userName> -p <password> [-c <connectionString>]
24+
25+
To run the sample, pass the following parameters to the sample program:
26+
27+
Required:
28+
29+
-u <username>: database user name
30+
31+
-p <password>: database password for the user
32+
33+
Optional:
34+
35+
-c <connectionString>: Use the specified connection string (Default: "localhost/sampledb:timesten_direct")
36+
37+
<connectionString> should be in Easy-Connect format:
38+
39+
\{<net_service_name> | <host>/<host_service_name>:\{ timesten_direct | timesten_client \}\}
40+
41+
`;
42+
}
43+
44+
function getCredentials(scriptName){
45+
let args = parseArgs();
46+
if(typeof args['-u'] === "undefined" ||
47+
typeof args['-p'] === "undefined"){
48+
console.error(usage(scriptName));
49+
throw "Error: Bad options format";
50+
}
51+
if ('-c' in args){
52+
if(typeof args['-c'] === "undefined")
53+
throw "Error: -c option requires 1 argument";
54+
}
55+
else{
56+
args['-c'] = "localhost/sampledb:timesten_direct";
57+
}
58+
return args;
59+
}
60+
61+
module.exports = {
62+
parseArgs: parseArgs,
63+
usage: usage,
64+
getCredentials: getCredentials
65+
}

languages/nodejs/README.md

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2+
3+
#TimesTen Node.js Samples
4+
5+
This folder contains Node.js samples that illustrate database connection and operations using the node-oracledb driver against TimesTen databases.
6+
7+
##Software & Platform Support
8+
The following table describes the tested operating systems, node-oracledb driver and TimesTen software versions.
9+
10+
OS | Node.js Version | node-oracledb Driver Version | TimesTen Client Driver | TimesTen Direct Driver
11+
------------- | ------- | ------------- | ------------ | ------
12+
Linux 64-bit | 12.7.0 |4.0.1 | 18.1.3.1.0+ | 18.1.3.1.0+
13+
macOS | 12.7.0 |4.0.1 | 18.1.3.1.0+ | N/A
14+
MS Windows 64-bit | 12.7.0 | 4.0.1 | 18.1.3.1.0+ | N/A
15+
16+
**NOTE**: Access to TimesTen Databases on any supported TimesTen server platforms can be achieved using the TimesTen client driver from any of the platforms listed above. For more information on supported TimesTen platforms, see [TimesTen Release Notes](https://docs.oracle.com/database/timesten-18.1/TTREL/toc.htm).
17+
18+
19+
## PRE-REQUISITES
20+
21+
1. Node.js language is installed.
22+
2. The node-oracledb driver is installed.
23+
3. A TimesTen database is created and data source is setup to access that database.
24+
4. Environment to access Node.js, node-oracledb driver and TimesTen data source are set up (i.e. the TimesTen environment script ttenv.sh/ttenv.csh has been executed)
25+
26+
For more information on setup, see [TimesTen In-Memory Database Open Source Languages Support Guide](https://docs.oracle.com/database/timesten-18.1/TTOSL/toc.htm).
27+
28+
## Known Problems and Limitations
29+
* REF CURSORs are currently not supported.
30+
* Using the NVARCHAR/NCHAR data types for input parameters in a PL/SQL procedure is currently not supported.
31+
* Large objects (LOBs) are currently not supported.
32+
* DML statements with RETURN INTO are currently not supported.
33+
* The value returned for the sub-second field of a PL/SQL output parameter of type Timestamp may be incorrect.
34+
35+
36+
37+
## Node.js sample programs
38+
### Download Samples
39+
40+
Node.js sample programs to access TimesTen databases can be downloaded from [Oracle/oracle-timesten-samples/languages/nodejs on github](https://github.com/oracle/oracle-timesten-samples/tree/master/languages/nodejs). Command-line command such as "git clone" can be used for github download. For example,
41+
42+
```
43+
% git clone https://github.com/oracle/oracle-timesten-samples
44+
```
45+
46+
Once the samples are downloaded locally, you can change to languages/nodejs subdirectory and run the samples directly from the local machine. Descriptions of the sample programs and examples of how to run them are below.
47+
48+
###simple.js
49+
50+
This simple sample program connects to a TimesTen database and performs the following operations:
51+
52+
* creates a table named Employees
53+
* inserts 3 rows to the table
54+
* select the rows from the table
55+
* drops the table
56+
* disconnects from the database.
57+
58+
Example:
59+
60+
```
61+
% node simple.js -u username -p password
62+
Table has been created
63+
Inserted 3 employees into the table
64+
Selected employee: ROBERT ROBERTSON
65+
Selected employee: ANDY ANDREWS
66+
Selected employee: MICHAEL MICHAELSON
67+
Table has been dropped
68+
Connection has been released
69+
```
70+
71+
72+
### sql.js
73+
The sql sample program connects to a TimesTen database and performs the following operations:
74+
75+
76+
* Creates a table called "vpn_users"
77+
* Populates the table with records
78+
* Performs a number of Selects, Updates and Deletes against the table
79+
* Drops the table
80+
* Disconnects from the database
81+
82+
Example:
83+
84+
```
85+
% node sql.js -u username -p password
86+
Table has been created
87+
Populating table
88+
Inserted 10 rows
89+
Inserted 20 rows
90+
Inserted 30 rows
91+
Inserted 40 rows
92+
Inserted 50 rows
93+
Inserted 60 rows
94+
Inserted 70 rows
95+
Inserted 80 rows
96+
Inserted 90 rows
97+
Inserted 100 rows
98+
Performing selects
99+
select(ed) 10 rows
100+
select(ed) 20 rows
101+
select(ed) 30 rows
102+
select(ed) 40 rows
103+
select(ed) 50 rows
104+
select(ed) 60 rows
105+
select(ed) 70 rows
106+
select(ed) 80 rows
107+
Performing updates
108+
update(ed) 10 rows
109+
update(ed) 20 rows
110+
Performing deletes
111+
delete(ed) 10 rows
112+
delete(ed) 20 rows
113+
Connection has been released
114+
```
115+
###queriesAndPlsql.js
116+
117+
The queriesAndPlsql sample program connects to a TimesTen database and performs a number of database operations with PL/SQL:
118+
119+
120+
* Creates a table named "items"
121+
* Populates the table
122+
* Performs Selects fetching 100 rows
123+
* Calls a PL/SQL procedure to update a row
124+
* Calls a PL/SQL procedure to delete a row
125+
* Drops the table
126+
* Disconnects from the database
127+
128+
Example:
129+
130+
```
131+
% node queriesAndPlsql.js -u username -p password
132+
Table has been created
133+
Inserting with executeMany ...
134+
100 Registries added
135+
Select some rows with one select ...
136+
20 Rows have been fetched and iterated
137+
Updating a row using an anonymous block ...
138+
Value before update: [ 'descr_0' ]
139+
Value after update: [ 'updated description' ]
140+
Delete a row using an anonymous block ...
141+
Rows after delete = [ 99 ]
142+
Connection has been released
143+
144+
```
145+
146+
147+
148+
## Documentation
149+
You can find the online documentation for Oracle TimesTen In-Memory Database in the [Documentation Library](https://docs.oracle.com/database/timesten-18.1/). Online documenation for the node-oracledb driver can be found [here](https://oracle.github.io/node-oracledb/doc/api.html).

0 commit comments

Comments
 (0)