Reading PostgreSQL with Google Script?

626 views
Skip to first unread message

Fernando Falcao

unread,
Jun 26, 2019, 9:53:28 AM6/26/19
to Google Apps Script Community
Hello everyone!

I have a PostgreSQL database hosted at Amazon hosting service. I could connect to this database using Google Data Studio and I already started the creation of some dashboards using Data Studio.

Now, my client submitted a request where it demands that a Google Spreadsheet can be populated, on daily basis, with the content of some tables that are part of the PostgreSQL database. I looked for support on the JDBC driver in order to write a Google Script to read the data, but unfortunately JDBC doesn't support PostgreSQL.

Does anyone know or have experience on using Google Script to read data from a PostgreSQL?

Thanks a lot in advance for sharing your experience with this challenge!!

Cheers,
Fernando

Dimu Designs

unread,
Jun 26, 2019, 1:35:02 PM6/26/19
to Google Apps Script Community
You are going to need some kind of intermediary to connect to the PostgreSQL database and run query requests through it.

One possible candidate is a Google Cloud Function. You can use Cloud Functions to create micro-services that allow you to run queries against the PostgreSQL database. Cloud Functions are written in Node.js and can be deployed as an HTTP endpoint which you can query from GAS using UrlFetchApp.fetch(). You're going to need a GCP account with Billing activated, however Cloud Functions have a generous free-usage quota which will serve for low-volume requests. 

Fernando Falcao

unread,
Jun 26, 2019, 4:32:50 PM6/26/19
to google-apps-sc...@googlegroups.com
Hi Dimus!

Thanks for your suggestion!
I am going to read about the use of cloud functions and see how they can help me!

Best,
Fernando

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-script-community.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/b682b073-44a7-4c00-a612-97a23fd2d981%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages