Giter Site home page Giter Site logo

dbhelper's Introduction

Database Helper

Version: 0.7.x

GitHub version GitHub release version

Getting Started

pip install git+https://github.com/attapon-th/dbhelper@latest

Use:

dbper --help

Install SQLAlchemy Database API

# mysql
# dsn=mysql+pymysql://user:pass@host:port/dbname
pip install pymysql

# postgres
# dsn=postgresql+psycopg2://user:pass@host:port/dbname
pip install psycopg2-binary

# vertica
# dsn=vertica+vertica_python://user:pass@host:port/dbname
pip install git+https://github.com/attapon-th/sqlalchemy-vertica-python.git@latest

# other sqlalchemy support

other sqlalchemy support https://docs.sqlalchemy.org/en/20/core/engines.html

Process SQL file

Usage

export DB_DSN=vertica+vertica_python://user:pass@host:port/dbname
dbper process test.sql 

# or 

dbper process --dsn "vertica+vertica_python://user:pass@host:port/dbname" test.sql

example test.sql****

-- test.sql
-- create table
CREATE TABLE IF NOT EXISTS test (
  id int,
  name text
);

-- insert data
INSERT INTO test (id, name) VALUES
  (1, 'a'),
  (2, 'b'),
  (3, 'c');

-- select data
SELECT * FROM test;

Dump SQL Query to CSV file

Usage

export DB_DSN=vertica+vertica_python://user:pass@host:port/dbname

dbper csv \
  --output test.csv
  "SELECT * FROM test"

# or
dbper csv \
  --dsn "vertica+vertica_python://user:pass@host:port/dbname" \
  --output test.csv
  "SELECT * FROM test"

Dump SQL Query to Parquet file

export DB_DSN=vertica+vertica_python://user:pass@host:port/dbname
dbper parquet \
  --output test.parquet \
  "SELECT * FROM test" 


# or
dbper parquet \
  --dsn "vertica+vertica_python://user:pass@host:port/dbname" \
  --output test.parquet \
  "SELECT * FROM test" 

dbhelper's People

Contributors

attapon-th avatar

Watchers

 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.