Giter Club home page Giter Club logo

oracledb-clean-schema's Introduction

oracledb-clean-schema

oracledb-clean-schema is a Python package for dropping all Oracle database objects in a schema without dropping the user itself.

Functionality

  • Drop all database objects in an Oracle database schema without dropping the user.
  • Objects can be dropped in parallel using multiple workers.

Quick Start

There are three primary modes of usage:

  • Python package
  • CLI
  • AWS Lambda

The environmental variable PROTECTED_SCHEMA_REGEX should be set prior to execution. The value must be a regular expression of schema names to guard against being dropped. The guard can be overridden by proving a force=true argument. A .env file in the current working directory can be used to supply this value.

Python package

import logging

from oracledb_clean_schema import drop_all

logging.basicConfig(level="DEBUG")

objs_remaining = drop_all(
    username="system",
    password="manager",
    hostname="localhost",
    database="orclpdb1",
    target_schema="hr",
    parallel=8
)
print(objs_remaining)

CLI

oracledb-clean-schema --help
usage: oracledb-clean-schema [-h] --username USERNAME --password PASSWORD --hostname HOSTNAME --database DATABASE --target-schema
                             TARGET_SCHEMA [--parallel PARALLEL] [--force FORCE]

Drop all objects in Oracle schema

options:
  -h, --help            show this help message and exit
  --username USERNAME   Database login user
  --password PASSWORD   Database login password
  --hostname HOSTNAME   Database service host
  --database DATABASE   Database service name
  --target-schema TARGET_SCHEMA
                        Database schema to clear
  --parallel PARALLEL   Number of worker threads
  --force FORCE         Override a protected schema exception
oracledb-clean-schema --username hr --password hr --hostname localhost --database orclpdb1 --target-schema hr --parallel 8

AWS Lambda

This example assumes the use of a custom domain name mapped to an API Gateway or ALB where the datapump lambda is mapped to a clean endpoint.

curl -XPOST "https://oracledb-util-api.somedomain.com/clean" -d \
'{
      "connection": {
        "username": "system",
        "password": "manager",
        "hostname": "some-host",
        "database": "ORCLPDB1",
        "secret": "Optional AWS SecretsManger secret name/arn with the above fields"
      },
      "payload": {
         "target_schema": "hr",
         "force": false,
         "parallel": 8
      }
}'

oracledb-clean-schema's People

Contributors

rgibbard avatar raginjason avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.