I am trying to deploy a Django REST API on Heroku. Normally I wouldn't have any issues with this but for this app, I am using a legacy database that exists on AWS. Is it possible for me to continue to use this remote database after deploying Django to Heroku? I have the database credentials all set up in settings.py so I would assume that it should work but I am not sure.
It should not pose any problem to connect with an database on AWS.
But be sure that the database on AWS is configured to accept external access, so that Heroku can connect.
And I would sugest that you take the credentials out of the source code and put it in the Config Vars that Heroku provide (environment variables).
Will it work? I think yes, provided you configure your project and database for external access.
Should you want it? How may queries does an average page execute? Some applications may make tens of queries for every endpoint and added wait can combine into seconds of waiting for every request.
Related
I have built an app that uses mysql database with Python, I would love to share some functionalities with different applications and that calls for an online database feature, kindly give me some insights over how i can move a python mysql database to online and how to make calls to it in order to facilitate for sharing of data between different applications.
I don't exactly know what you are calling a python database but there are some options here that you might want to consider
First, use heroku to host your app and heroku postgress to host your databaseOr you can use an EC2 aws machine to host your app and it's database (in case it's a custom code that you can't call from a browser using heroku)with both of these options you can access you database and the appp with the second one you can install other services such as ssh and other.
I have a desktop app that is built on top of Django framework and frozen to .exe using PyInstaller. The idea behind it, that an application should connect to remote database(PostgreSQL) on VPS. That VPS is serving static files for this application too. So here is the question - is that option secure? Can potential hackers connect to my database and make a mess in it or replace original DB with the fake one? If they can, how should I fix that?
It is not safe to connect to a remote database in a scenario that you are describing.
For a potential hacker its a piece of cake to figure out the credentials of the remote database that you are using.
And to answer your question it will be difficult for the hacker to replace the DB with a fake one. But it wont stop him from getting all the data from your DB and modifying it.
What you should do is to have a rest-api endpoint or a grapghql endpoint to interact with the database. and you can hit that endpoint from the client app.
I have a python django application that I published to heroku by connecting to github. I want some people to be able to add some information to the database from the website. If I make changes to the code, push to github and deploy the branch the database will go back to how it was at first. How can update my code for the app without changing the database?
If you host your database on a separate server, like with Amazon RDS or Heroku Postgres, and configure your code to connect to this remote host, you should have sufficient decoupling to avoid what you are talking about.
How do I see the database for my heroku web app?
I just want to verify if users are being registered, properly, etc.
I am using Flask-SQLAlchemy Python, if that makes a difference.
You can connect directly to it using something like PGAdmin, look at the output of heroku config for your application to get your database URL which you can breakup to use in GUI tools.
I'm having a lot of trouble with getting web2py to work on Heroku. I can't even get a basic app to work. Whenever I go to my herokuapp page, it says
Application Error
An error occurred in the application and your page could not be served. Please try again in a few moments.
If you are the application owner, check your logs for details."
It may be a problem with the DB setup. By default web2py only supports sqlite or Google App Engine (GAE). It's probably trying to initialize sqlite databases on Heroku's read-only filesystem.
Either disable the DB code temporarily to see if this is indeed the case, or configure a connection to a supported database (MySQL, S3, etc).
Take a look at the "official" Heroku script in scripts/setup-web2py-heroku.sh
Try with a simple wsgi application first. Here is some tutorial: http://webpython.codepoint.net/wsgi_tutorial
Web2py will work without any problems if you can run simple wsgi apps.