0

I have a flask application running on Heroku which reads and writes a Heroku PostgreSQL Database. I then want to have a local python application running on a client's computer which only reads from this database. The idea is to be able to configure the program that's running locally from anywhere in the world with the web application running on Heroku.

The flask application is already up and running and modifies the database correctly. Now I have to connect to this database from a computer with a python application running locally.

To connect to a Heroku Postgres DB externally, Heroku provides the following [solution] (https://devcenter.heroku.com/articles/connecting-to-heroku-postgres-databases-from-outside-of-heroku#credentials/)

I want to access this cloud database with a local application running on the clients computer. However, to get the DATABASE_URL, at some point I have to login to Heroku with my account email and password which give access to everything. I was hoping there could be a way of accessing this external Database with a user with restricted permission to it. In my case, I want to access it with a user who can only read the data and leave my Heroku account out of this.

Using PostgreSQL was my first approach but I stumbled upon this issue. Am I right in that it IS an issue?

My second approach is to use google drive API to link my web application to my local application. The web application will modify a file and the local application will read from it with a user with READ-ONLY permission. In this way, if the local application gets reversed engineered or hacked in some way, no critical information is revealed. I think I can do this with google drive API.

Is there a better approach? I'm using free tools and the data handled by the database or google-drive API is lightweight for now. I feel that if I would want to scale the application, google drive API wouldn't be the best solution.

1 Answer 1

2

If your code must run on clients' computers the best option is probably to run a server-side API and connect to that instead of making direct database connections. That way you don't expose your database credentials or your Heroku credentials to your users.

By default, Heroku database URLs give read / write access. Putting an API between your database and your client-facing code also lets you enforce read-only behaviour from the second codebase.

If this isn't feasible for some reason, you could create new read-only credentials for your database and expose just this new read-only database URL in a very small server-side API. Your second application could load the connection information from your API and then make database queries directly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.