Skip to content

Export result of a Postgres SQL query to Google Spreadsheets

Notifications You must be signed in to change notification settings

cloudloyalty/pg-sheets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pg-sheets

Export result of a Postgres SQL query to Google Spreadsheets.

Usage of pg-sheets:

  -query string
        SQL file to execute
  -dsn string
        database connection string
  -spreadsheet string
        spreadsheet ID string
  -sheet int
        sheet ID integer
  -append
        append to spreadsheet, not overwrite
  -header
        include header in result
  -credentials string
        credentials file (default "credentials.json")
  -token string
        token storage file (default "token.json")

Usage example:

./pg-sheets -query=query.sql \
            -dsn=postgresql://localhost/db?sslmode=disable \
            -spreadsheet=14KZv6vclr5CZ5IdTmnpc-XXYYYZZZ0001122233 \
            -sheet=0 \
            -header \
            -append

How to create credentials.json:

At first run you will be prompted for the auth token that will be saved in token.json for later use.

How to obtain spreadsheet and sheet values from the URL:

https://docs.google.com/spreadsheets/d/14KZv6vclr5CZ5IdTmnpc-XXYYYZZZ0001122233/edit#gid=12345
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^          ^^^^^
                                                            `-- spreadsheet                `-- sheet

About

Export result of a Postgres SQL query to Google Spreadsheets

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages