It's basically the code of this article. The main goal is to create a Heroku a global controller to retrieve datas from postgreSQL to your Google Sheets spreadsheet.
Just fork the project, and deploy it on Heroku as described in the above article.
Go to app.py
file > change the global variables with your own:
DB_NAME
DB_USERNAME
DB_PASSWORD
Consider changing them with some functions if the (DB_NAME,DB_USERNAME,DB_PASSWORD) are not the same depending on your database connection string.
- Once this repo is forked, please keep it as a PRIVATE repo, otherwise it will leak your own database password
- Enabling https by having CORS parts code in
app.py
+ creating both filescert.pem
andkey.pem
is not mandatory - Don't use this as production server, it's only for demonstration purpose.
git clone https://github.com/jadynekena/python-server-heroku
cd python-server-heroku
python app.py
Then go to http(s)//127.0.0.1:5000/<YOUR-DB-HOST>/<YOUR-SQL-STATEMENT>/[true]
.
- The last parameter is set to
true
if your SQL statement is not a SELECT one. - Force to https if you enabled CORS. Bypass all security alerts while it's a self-generated certificate, run on localhost.