How to use database in Heroku - python

I am new in web applications and I created first application in django. I decided to deployment my project in Heroku. But I'm so confused about database. I click "Heroku pricing" and I see 4-5 options. Free, Hobby, Standart, etc. And then i see databases options except these options. What is this?? as I said, this is my first applications and I dont know much about web servers. but as far as I know, service providers offer certain packages. These packages include RAM, Storage, Traffic, Database, ... etc.
In short, my questions are:
Is database included in heroku pricing?
I saw "connection 0 of 20" while using the heroku database. Does this mean only 20 users can access the site?
When I browsed the Heroku site, I didn't see any storage information in the pricing section. no storage pricing on cloud-based deployments?
Can I create a different database outside of the heroku environment and connect it to heroku?
every answer given informs and improving me. Thank you

Heroku PostgreSQL Hobby Dev pack is free
Go to Heroku dashboard
After creating an app, click on it
Go to Resources
Under Add-ons, in search bar type postgresql
Click on Heroku postgres
In plan name select Hobby Dev Free
Then Click on Heroku Postgres and get your credentials

Related

django , node js, php website hosting and domain information

I would like to about Django, node js, and PHP hosting along with MySQL database.
how can we host them online, please suggest to me some websites for that? can I host the Django website with MySQL on GoDaddy, Bluehost or do I need to use cloud services like AWS Azure, etc?
how to set up a domain for these websites.
what is the difference in hosting the website using
can you host these website on a Cpanel and is there any other way also to host
The choice is really yours, you can install all of them on a single VPS server which
should be powerful enough to run them and you need to configure your Nginx or Apache2 to access them on a proxy level or with a different subdomains, or you can host them on separate servers, when you will get the domain you need to point it to your server(s) or create a reverse proxy which in turn will reflect another domain. Platforms like Azure provide more control over DevOps. Cpanel is just a tool that allows you to have more simple the process of hosting a web site. Some platforms like Heroku make the hosting process much more easier, you just deploy your code and its running like a charm no need to configure anything or install certificates, the only downside is that when you would want to scale your app the resources are stupid expensive at Heroku. I would prefer a VPS server over all of these, because of more control and flexibility.

Use an external database in Django app on Heroku

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.

How to solve operationError: no such table

I'm setting up my new website, but the web have some problem. It gives me an OperationalError at /topics/ and no such table: toms_topic.
This is a Heroku web dyno, running Django2.2 and Python 3.7.3.
I have executed
python manage.py migrate
and when I go to the db.sqlite I find the table toms_topic exists.
And everybody can goto the website https://cblingh.herokuapp.com for take more information
My last website haven't this problem,maybe I add image this time,and the image is foreignkey with topic.But i not sure it's the key of this problem yet.The topic have two foreignkey (entry,image).
You can't use SQLite on Heroku. Its filesystem is dyno-local and ephemeral. Any changes you make to it will be lost whenever your dyno restarts. This happens frequently (at least once per day).
Heroku offers good support for client-server databases. If you want to use Heroku you'll have to switch to one. Their own PostgreSQL service works well and is available out of the box. If you prefer other databases feel free to browse the data store addons.

What GIT / workflow do I use to avoid overwriting my server side Django users, with my local users who are dummy/test users?

I am developing a Django application in Atom locally, and then on pythonanywhere, when I'm ready, I'm doing a GIT PUSH command after syncing those changes to GITHUB. The problem is, at some point, those changes which were pushed through from my local development env have overwritten all my live users with just the local dummy users I've been using for testing and development.
Basically, I'm testing the login and registration system locally, logging in and registering with lots of dumb emails. Once I was happy it was working, I synced the Django code I'd changed to GITHUB (with the desktop app) and then did a GIT PUSH command on a PythonAnywhere (my server) console. The sqlite DB is included in those updates/sync - is that correct? Or should it just be totally ignored?
I just realised, that one (perhaps all?) pushes have overwritten my sqlite DB, and there were perhaps 30 or so actual users who had signed up on the website whose data is no longer registered on the site. I managed to find a trace of them in the Django Admin logs, and I've found the version history of the Sqlite DB on GITHUB, but my question is - how do I avoid this happening?
What is the workflow to avoid this situation in the future? And is there a command I can run in shell to get those users back into my 'live' database from the backedup SQlite file?
I know this is a simple question, but I'm new to development and I'm slowly getting there with troubleshooting the code, but versioning, GIT, and workflow are tricky things to get my head around.

How and where I can deploy my Flask app build on my local machine and connected to my local mysql-server?

I have a flask app with simple functionalities of a blog website codes given in below Github repo -
https://github.com/vivanks/flaskhost
It's data like user login details and blogs are stored in my system MySql-server.
On local machine it's working perfectly fine.
Now I want it to be deployed over internet.
What I tried so far is :
Heroku but problem with heroku is it need some postgressql and my whole data is stored in MySQL so I can't conver it.
Hosting flask part on Heroku and Database on 000webhost.com but 000webhost don't allow to connect to database outside of 00webhost
Hosting on http://pythonanywhere.com/ but then again failed also It don't support import MySQLdb instead it supports sqlalchemy
I want some way or something stable way through which I can export my data stored in mysql and don't have to change my code.
It would be great if you provide step by step guide.
P.S I don't have problem paying small amount

Categories

Resources