Code Monkey home page Code Monkey logo

google_spreadsheets_fdw's Introduction

Google Spreadsheets FDW

Multicorn based PostgreSQL foreign data wrapper for Google Spreadsheets

Installation

Requirements

PostgreSQL 9.1+ with Multicorn extension installed.

If you haven't used Multicorn yet, enable it with:

create extension multicorn;

From source:

git clone https://github.com/TheDeadJoe/google_spreadsheets_fdw
cd google_spreadsheets_fdw
python setup.py install

Usage

create server multicorn_srv foreign data wrapper multicorn options (
    wrapper 'google_spreadsheets_fdw.GoogleSpreadsheetFDW'
);

create foreign table my_table (
    id int default nextval('my_seq'),
    foo varchar,
    bar int,
    baz float
) server multicorn_srv options (
    gskey 'zVshdGDuaQKKaQoXqNOwjeTWcxcUtOlSJDZoLeIMUsYx',
    keyfile '/path/to/credentials.json',
    sheet '0',
    row_id 'id'
);

Options

  • gskey - "ID" of a spreadsheet (the 44 char length part between /spreadsheets/d/ and /edit/ from spreadsheet URL)
  • keyfile - path to Google Cloud Services credentials json file
  • sheet - index of a sheet
  • row_id - name of the column which value will be treated as an ID of the whole row

Example

We start with an empty spreadsheet:

1

Let's insert some data into it:

insert into my_table(foo, bar, baz) values ('a', 1, 0.1);
insert into my_table(foo, bar, baz) values ('b', 2, 0.2);
insert into my_table(foo, bar, baz) values ('c', 3, 0.3);
insert into my_table(baz, bar, foo) values (0.4, 4, 'd') returning *;

Spreadsheet contains our data.

2

Now let's try retrieve the data:

select * from my_table;

The result:

3

Of course, we can also perform other SQL operations e.g.:

update my_table set bar = 9, baz = 0.9 where bar = 2;

delete from my_table where bar > 5;

google_spreadsheets_fdw's People

Contributors

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