Giter VIP home page Giter VIP logo

py-sql2sql's Introduction

sql2sql

A simple lightweight tool to perform ETL jobs between two SQL databases

Installation

pip3 install --user sql2sql

Usage

It's assumed that the SQL database driver is used with cursors.

Basic Example

# Setting up the db connections
import psycopg2
import cx_Oracle

oracle = cx_Oracle.connect("username", "password", "url/db")
psql = psycopg2.connect("dbname='dbname' user='username' host='url' password='password'")


# Actual usage
from sql2sql.objects import ETL

extract = "SELECT col1, col2 FROM some_table"
def transform(each_row):
    print(each_row[0], each_row[1])
    each_row = (each_row[0] + 1, each_row[1] + 2)
    return each_row
load = "INSERT INTO new_table(col1, col2) VALUES (%s, %S)"

ETL().from_conn(oracle).to_conn(psql).extract(extract).transform(transform).load(load).execute()

Order of operation

The actual order of function chain does not matter, as it stores everything and performs it during execute. The order of operation is

  • from_conn
  • from_initial_query
  • to_conn
  • to_initial_query
  • extract
  • transform and load
  • from_final_query
  • to_final_query

Versions

1.0.0

  • Switched up orders

0.0.1

  • First Publish

py-sql2sql's People

Contributors

joeyism avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

knightcn1983

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.