@db2lake/driver-oracle
v0.2.0
Published
Oracle source driver for db2lake
Maintainers
Readme
@db2lake/driver-oracle
Oracle source driver for the @db2lake pipeline framework. It streams rows from Oracle using oracledb pools and supports simple cursor-based pagination.
Key points
- Uses
oracledb'screatePoolandpool.getConnection()to manage connections. - Streams data in batches through an async generator:
fetch()yields arrays of row objects. - Cursor-based pagination is supported by updating a parameter in
paramsbetween pages.
Install
Install the published package:
npm install @db2lake/driver-oracleProject structure
├── src/
│ └── index.ts # OracleSourceDriver implementation
│ └── type.ts # Oracle configuration types
└── package.json # Package metadataNote: oracledb may require native dependencies and a supported Oracle client on the host machine. See the oracledb documentation for installation details.
Usage
import { OracleSourceDriver, OracleConfig } from '@db2lake/driver-oracle';
const config: OracleConfig = {
// Use bind placeholders (e.g. :id) in your SQL
query: 'SELECT * FROM users WHERE id > :id ORDER BY id FETCH NEXT 100 ROWS ONLY',
params: [0], // initial params
cursorField: 'id', // field from last row used as next cursor
cursorParamsIndex: 0, // index in params to replace with cursor value
poolAttributes: { user: 'app', password: 'secret', connectString: 'localhost/XEPDB1' }
};
const driver = new OracleSourceDriver(config);
for await (const batch of driver.fetch()) {
for (const row of batch) {
// process row
}
}
await driver.close();Configuration
query(string) - SQL query with placeholders (Oracle bind syntax like:id).params(any[]) - Parameter array passed toconnection.execute(query, params); the driver clones this array for paging and updatesparams[cursorParamsIndex]whencursorFieldis configured.cursorField(string | undefined) - When provided, pagination continues by reading this field from the last row of each batch and placing it intoparams[cursorParamsIndex]for the next query.cursorParamsIndex(number | undefined) - Which index inparamsto replace with the cursor value.poolAttributes(object | undefined) - Options forwarded tooracledb.createPool(for example{ user, password, connectString }).
License
MIT
