GithubHelp home page GithubHelp logo

vertica-csv's Introduction

Vertica SQL to CSV

Outputs vertica query results as proper CSV.

Uses python's csv library to properly format CSV to one's liking. Outputs the result to stdout, can be piped to any other process.

Tries to mimic the command line arguments of vsql, but had to make some changes to keep it simple and versatile for csv.

Installation

  • Clone the repo and change to that directory
git clone https://github.com/kfzteile24/vertica-csv.git
cd vertica-csv
  • Initialize the virtual environment (developed and tested on Python 3.7, but should work fine with Python 3.5 as well). Depending on the OS you might have to specify whether it's -p python3 or -p python3.6 or omit it entirely.
python -m vitualenv -p python3 .venv
.venv/bin/pip install -r requirements.txt

Example usage

# Simplest command - execute on localhost with the current user and no password
./vsqlcsv db_name -c "SELECT * FROM public.sales LIMIT 10;"

# Remote connection, with user and password specification
./vsqlcsv --host 192.168.56.20 -U dbadmin -w letmein db_name --header -quoting all -c "SELECT * FROM public.sales LIMIT 10;"

# Piping command and sending output to file
cat query.sql | ./vsqlcsv --host 192.168.56.20 -U dbadmin db_name --header -quoting all > results.csv

You could also copy it to /usr/local/bin/ and thus make it available regardless of pwd.

vertica-csv's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  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.