Giter Club home page Giter Club logo

dbmanager's Introduction

DBmanager

Data downstream/upstream manager for SQL databases

Installation

Clone or download this repo on your system. Go inside the root directory of the package, and type

pip install .

Set up connections parameters

Add the following environment variables to .bashrc or .bash_profile:

export DBMANAGER_USER=yourusername
export DBMANAGER_PSWD=yourpassword
export DBMANAGER_HOST=dbhostaddress
export DBMANAGER_PORT=yourport # try 3373

Don't forget to source the file.

Downloading data

The database connector contains downstream, which is a convenience method. As an argument, it takes a string with SQL code or a string path to a SQL file. Either way, the SQL code string can be composed of several statements, each one ending with a ;. The connector will only fetch data from the last statement. The purpose of this functionality is to allow for temporary tables to be created in prior steps.

from dbmanager import dbmanager

# Initialize connector
conn = dbmanager.DB_connector()

# This call returns a numpy array with the data and
# list of strings with the column names:
data, cols = conn.downstream("SELECT * FROM my_db.my_table;")

# Alternatively, you could also type the path to a sql script:
data, cols = conn.downstream("/home/files/query.sql")

# If you use pandas, it can be easily transformed
# into a dataframe:
df = pd.DataFrame(data, columns=cols)

Uploading data

Data can be written to the database via the upstream method.

dbmanager's People

Watchers

Jesus Martinez Manso 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.