GithubHelp home page GithubHelp logo

rsdf's Introduction

RSDF

Build Status PyPI version License

Set of utils to connect Pandas DataFrames and Redshift. This module will add a new function to the DataFrame object. Inspired by josepablog gist.

Installation

To install rsdf, simply use pip:

$ pip install rsdf

If you were using the older version, you can also install it with pip:

$ pip install git+git://github.com/bufferapp/rsdf.git@d1a5feca220cef9ba7da16da57a746dfb24ee8d7

Usage

Once rdsf is imported, the DataFrame objects will have new functions:

import pandas as pd
import rsdf


engine_string = 'redshift://user:password@endpoint:port/db'

users = pd.read_sql_query('select * from users limit 10', engine_string)

users['money'] = users['money'] * 42

# Write it back to Redshift
users.to_redshift(
    table_name='users',
    schema='public',
    engine=engine_string,
    s3_bucket='users-data',
    s3_key='rich_users.gzip',
    if_exists='update',
    primary_key='id'
)

Alternatively, if no engine is provided, the rsdf module will try to figure out the engine string from the following environment variables:

  • REDSHIFT_USER
  • REDSHIFT_PASSWORD
  • REDSHIFT_ENDPOINT
  • REDSHIFT_DB_NAME
  • REDSHIFT_DB_PORT

Since rsdf uploads the files to S3 and then runs a COPY command to add the data to Redshift you'll also need to provide (or have them in the environment loaded) these two AWS variables:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY

License

MIT © Buffer

rsdf's People

Contributors

davidgasquez avatar michael-erasmus avatar nickhould avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rsdf's Issues

Add docstrings

Document functions to describe their parameters and what they do

Add tests

These could be integration tests that actually hit redshift.

Add S3 cleanup

After uploading the data to Redshift, we can delete the S3 object.

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.