Code Monkey home page Code Monkey logo

bq2psql-tool's Introduction

bq2psql-tool

Description

bq2psql-tool is an agnostic CLI to expose commands which allows you to import data (and other related actions) between BigQuery and Postgres.

Format:

bq2psql [command] [--flags]

Tech Stack:

Git

Usage

There are available the following commands:

  • Import

Command: [import]

The import command allows you to import data from BigQuery to Postgres.

Flags

Required flags
  • --project-id= the project id where we want to run the query.
  • --query= SQL query to get rows from BigQuery.
  • --table-name= The destination name table.
  • --table-schema= The destination table schema.
  • --postgres-address= The database address and port.
  • --postgres-user= The database user.
  • --postgres-password= The database password.
  • --postgres-database= The destination name database.
Optional flags

Example

Here an example of this command:

bq2psql import \
  --project-id=world-fishing-827 \
  --query="SELECT * FROM vessels" \
  --table-name="vessels_2021_02_01" \
  --table-schema="flag VARCHAR(3), first_transmission_date VARCHAR, last_transmission_date VARCHAR, id VARCHAR, mmsi VARCHAR, imo VARCHAR, callsign VARCHAR, shipname VARCHAR" \
  --postgres-address="localhost:5432" \
  --postgres-user="postgres" \
  --postgres-password="XaD2sd$34Sdas1$ae" \
  --postgres-database="postgres" 

When you execute this command, under the hood happens the followings steps:

  • The CLI check if the destination table exists (and creates it)
  • The CLI executes the SQL query and gets the rows
  • The CLI parses the results from RowIterator to JSON files. The keys are the name of each column.
  • The CLI imports the parsed data to Postgres.

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.