postgreSQL, Apps Script & datastudio

243 views
Skip to first unread message

Emeric HOCHART

unread,
Dec 17, 2019, 7:55:32 AM12/17/19
to Google Apps Script Community
Hello !

Is it possible to connect to a database postgreSQL ? 

Otherwise

I know that's possible to connect to a database postgreSQL with datastudio. 
Can we get the datas catched from datastudio with GAS ?



Dimu Designs

unread,
Dec 17, 2019, 8:50:11 AM12/17/19
to Google Apps Script Community
Currently, the closest you can get to native support for PostgreSQL on Google's Cloud Platform is Cloud PostgreSQL, but its still in beta and last I checked it is not natively supported by Apps Script's JDBC API (at least not yet). 

However, its possible set up a Google Cloud function to act as an intermediary between Apps Script and your PostgreSQL database. But you'll have to create a custom community connector to integrate it with Datastudio.

Alex

unread,
Dec 17, 2019, 8:51:53 AM12/17/19
to Google Apps Script Community
Hi!

As I can understand your DB have to have JDBC connection property. If it is installed/enabled you can connect to the DB via jdbc.

Best, Alex.

Dimu Designs

unread,
Dec 17, 2019, 11:25:02 AM12/17/19
to Google Apps Script Community
@Alex Unfortunately, Apps Script's JDBC API does not natively support PostgreSQL...see documentation.

Emeric HOCHART

unread,
Dec 18, 2019, 1:37:23 AM12/18/19
to Google Apps Script Community
There is an npm module which allows you to connect to a database in postgresql.

https://www.npmjs.com/package/pg

It seems to me that we can integrate npm modules into an apps script project

Do you think that in theory I could then establish a connection using this npm module directly in a server-side script?

Wilson Galter

unread,
Dec 18, 2019, 5:02:14 AM12/18/19
to Google Apps Script Community
Interesting topic. I have not tried this yet but I will soon.
Maybe this article coul help us.
https://www.cdata.com/kb/tech/postgresql-odbc-mysql-apps-script.rst

Emeric HOCHART

unread,
Dec 18, 2019, 6:25:08 AM12/18/19
to Google Apps Script Community
I know this link. Unfortunately it requires using SQL Gateway for PostgreSQL.
I try to use the npm pg module and I come back to you but I already have several errors related to the dns in particular.

Le mardi 17 décembre 2019 13:55:32 UTC+1, Emeric HOCHART a écrit :

Alex

unread,
Dec 23, 2019, 10:55:01 AM12/23/19
to Google Apps Script Community
@Dimu thank you!

Aume RRPMP

unread,
Jan 18, 2023, 10:39:28 PM1/18/23
to Google Apps Script Community
Hi, I found this group convo and I was wondering if someone could recommend an up to date path towards querying postgres data into a app script.

Thank you in advance.
Reply all
Reply to author
Forward
0 new messages