npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@azimutt/connector-oracle

v0.1.3

Published

Connect to Oracle, extract schema, run analysis and queries

Downloads

306

Readme

Oracle connector

This library allows to connect to Oracle, extract its schema and more...

It lists all schemas, tables, columns, relations and types and format them in a JSON Schema.

This library is made by Azimutt to allow people to explore their Oracle database. It's accessible through the Desktop app (soon), the CLI or even the website using the gateway server.

Feel free to use it and even submit PR to improve it:

Publish

  • update package.json version
  • update lib versions (pnpm -w run update + manual)
  • test with pnpm run dry-publish and check azimutt-connector-oracle-x.y.z.tgz content
  • launch pnpm publish --no-git-checks --access public

View it on npm.

Dev

If you need to develop on multiple libs at the same time (ex: want to update a connector and try it through the CLI), depend on local libs but publish & revert before commit.

  • Depend on a local lib: pnpm add <lib>, ex: pnpm add @azimutt/models
  • "Publish" lib locally by building it: pnpm run build

Local Setup

1. Run in Docker

You can use the Oracle Database free version:

docker run --name oracle_sample -p 1521:1521 -e ORACLE_PWD=oracle container-registry.oracle.com/database/free:23.4.0.0-lite

or

docker run --name oracle_sample -p 1521:1521 -e ORACLE_PWD=oracle container-registry.oracle.com/database/free:latest

2. Setup your database

Connect with host (localhost), port (1521), user (SYSTEM) and pass (oracle), then create a user and grand useful rights:

CREATE USER C##azimutt IDENTIFIED BY azimutt;
GRANT UNLIMITED TABLESPACE TO C##azimutt;
CREATE ROLE C##azimutt_role;
GRANT CREATE SESSION, CREATE TABLE, CREATE SEQUENCE, CREATE VIEW, CREATE MATERIALIZED VIEW, CREATE TYPE, CREATE TRIGGER to C##azimutt_role;
GRANT C##azimutt_role TO C##azimutt;

3. Fill your database

Connect with host (localhost), port (1521), user (C##azimutt) and pass (azimutt) or using oracle:thin:C##azimutt/azimutt@localhost:1521, then add some tables and data:

CREATE TYPE tag_list_t AS VARRAY(10) OF VARCHAR2(20);
ALTER TYPE tag_list_t MODIFY LIMIT 12;
CREATE TYPE address_t AS OBJECT (
    street VARCHAR2(200),
    city   VARCHAR2(200),
    state  CHAR(2),
    zip    VARCHAR2(20)
);

CREATE TABLE users (
    id              NUMBER GENERATED BY DEFAULT AS IDENTITY,
    name            VARCHAR2(50)            NOT NULL,
    role            VARCHAR2(10)            NOT NULL,
    email           VARCHAR2(255)           NOT NULL,
    email_confirmed BOOLEAN   DEFAULT false NOT NULL,
    settings        JSON,
    created_at      TIMESTAMP DEFAULT systimestamp,
    PRIMARY KEY (id),
    CONSTRAINT users_lower_email_chk CHECK (email = LOWER(email)),
    CHECK (name <> email)
);
COMMENT ON TABLE users IS 'List all users';
COMMENT ON COLUMN users.name IS 'The user name';
CREATE UNIQUE INDEX users_email_uniq ON users (email);
CREATE INDEX users_role_idx ON users (role);
CREATE INDEX users_plan_idx ON users (json_value(settings, '$.plan.name'));
CREATE INDEX users_full_idx ON users (name, email, json_value(settings, '$.plan.name'), json_value(settings, '$.color'));

CREATE VIEW admins AS SELECT id, name, email FROM users WHERE role = 'admin';
COMMENT ON TABLE admins IS 'Only admins';

CREATE MATERIALIZED VIEW guests AS SELECT id, name, email FROM users WHERE role = 'guest';
COMMENT ON MATERIALIZED VIEW guests IS 'Only guests';


CREATE TABLE posts (
    id         NUMBER GENERATED BY DEFAULT AS IDENTITY,
    title      VARCHAR2(50) NOT NULL,
    content    CLOB,
    created_at TIMESTAMP DEFAULT systimestamp,
    created_by NUMBER       NOT NULL,
    PRIMARY KEY (id),
    CONSTRAINT posts_created_by_fk FOREIGN KEY (created_by) REFERENCES users (id)
);

CREATE TABLE post_authors (
    post_id NUMBER,
    user_id NUMBER,
    CONSTRAINT post_authors_pk PRIMARY KEY (post_id, user_id),
    CONSTRAINT post_authors_post_id_fk FOREIGN KEY (post_id) REFERENCES posts (id),
    CONSTRAINT post_authors_user_id_fk FOREIGN KEY (user_id) REFERENCES users (id)
);

CREATE TABLE post_author_details (
    detail_post_id NUMBER,
    detail_user_id NUMBER,
    role           VARCHAR2(10) NOT NULL,
    CONSTRAINT post_author_details_pk PRIMARY KEY (detail_post_id, detail_user_id),
    CONSTRAINT post_author_details_post_user_fk FOREIGN KEY (detail_post_id, detail_user_id) REFERENCES post_authors (post_id, user_id)
);

CREATE TABLE ratings (
    user_id   NUMBER       NOT NULL,
    item_kind VARCHAR2(50) NOT NULL,
    item_id   NUMBER       NOT NULL,
    rating    NUMBER       NOT NULL CHECK ( 0 <= rating AND rating <= 5 ),
    review    VARCHAR2(255),
    CONSTRAINT ratings_pk PRIMARY KEY (user_id, item_kind, item_id),
    CONSTRAINT ratings_user_id_fk FOREIGN KEY (user_id) REFERENCES users (id)
);
ALTER TABLE ratings ADD CONSTRAINT ratings_item_id_users_fk FOREIGN KEY (item_id) REFERENCES users (id) DISABLE NOVALIDATE;
ALTER TABLE ratings ADD CONSTRAINT ratings_item_id_posts_fk FOREIGN KEY (item_id) REFERENCES posts (id) DISABLE NOVALIDATE;


-- Insert data
INSERT INTO users (name, role, email, settings) VALUES ('Loïc', 'admin', '[email protected]', '{"color": "red", "plan": {"id": 1, "name": "pro"}}');
INSERT INTO users (name, role, email, settings) VALUES ('Jean', 'guest', '[email protected]', null);
INSERT INTO users (name, role, email, settings) VALUES ('Luc', 'guest', '[email protected]', null);
INSERT INTO posts (title, content, created_by) VALUES ('Oracle connector', null, 1);
INSERT INTO post_authors (post_id, user_id) VALUES (1, 1);
INSERT INTO post_authors (post_id, user_id) VALUES (1, 2);
INSERT INTO post_author_details (detail_post_id, detail_user_id, role) VALUES (1, 1, 'author');
INSERT INTO ratings (user_id, item_kind, item_id, rating) VALUES (3, 'posts', 1, 4);
INSERT INTO ratings (user_id, item_kind, item_id, rating) VALUES (3, 'users', 1, 5);

Remove everything with:

DROP MATERIALIZED VIEW guests;
DROP VIEW admins;
DROP TABLE ratings;
DROP TABLE post_author_details;
DROP TABLE post_authors;
DROP TABLE posts;
DROP TABLE users;
DROP TYPE address_t;
DROP TYPE tag_list_t;