Update sqlite database based on changes in production - python

I am deploying a Django App using Elastic Beanstalk on AWS. The app has a function whereby user can register their details.
The problem is when I make small changes to my app and deploy this new version I loose the registered users since their information isn't in my local database (only the database on aws).
Is there any way to download the modifications to the database during production so that I can keep these changes when I redeploy.
I'm not using AWS RDS, I simply bundle the .SQLite file with my source code and deploy to Elastic Beanstalk.
Thanks in Advance.

Don't bundle the development .sqlite file with the production stuff. It needs to have its own .sqlite file and you just need to run migrations on the production one.

Related

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 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

How is Deploying Flask on AWS Elastic Beanstalk different from running script?

What is the difference between deploying a Flask application on an ec2 instance (in other words running your script on any computer) and deploying a Flask application via AWS Elastic Beanstalk? The Flask deployment documentation says that:
While lightweight and easy to use, Flask’s built-in server is not
suitable for production as it doesn’t scale well and by default serves
only one request at a time. Some of the options available for properly
running Flask in production are documented here.
One of the deployment options they recommend is AWS Elastic Beanstalk. When I read through Amazon's explanation of how to deploy a Flask app, however, it seems like they are using the exact same server application as comes built-in to Flask, which for example is single threaded and so cannot handle simultaneous requests. I understand that Elastic Beanstalk allows you to deploy multiple copies, but it still seems to use the built-in Flask server application. What am I missing?
TL;DR Completely different - Elastic Beanstalk does use a sensible WSGI runner that's better than the Flask dev server!
When I read through Amazon's explanation of how to deploy a Flask app, however, it seems like they are using the exact same server application as comes built-in to Flask
Almost, but not quite.
You can confirm that this isn't the case by removing the run-with-built-in-server section yourself - i.e. the following from the example:
if __name__ == "__main__":
# Setting debug to True enables debug output. This line should be
# removed before deploying a production app.
application.debug = True
application.run()
You'll stop being able to run it yourself locally with python application.py but it'll still happily run on EB!
The EB Python platform uses its own WSGI server (Apache with mod_wsgi, last I looked) and some assumptions / config to find your WSGI callable:
From Configuring a Python project for Elastic Beanstalk:
By default, Elastic Beanstalk looks for a file called application.py to start your application. If this doesn't exist in the Python project that you've created, some adjustment of your application's environment is necessary.
If you check out the docs for the aws:elasticbeanstalk:container:python namespace you'll see you can configure it to look elsewhere for your WSGI application:
WSGIPath: The file that contains the WSGI application. This file must have an "application" callable. Default: application.py
Elastic compute resources (AWS and others) generally allow for dynamic load balancing, and start more compute resources as they are needed.
If you deploy on a single ec2 instance, and this instance reaches capacity, your users will experience poor performance. If you deploy elastically, new resources are dynamically added as to ensure smooth performance.

How can update my code for a django app without earasing the existing database (Read Description)?

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 to migrate local datastore in google appengine python SDK 1.8.1

I am using GAE python-SDK 1.7.1 and have to update to 1.8.1 and migrate the local datastore to HRD. The appserver is also running locally.
So far, all information i found is a procedure if you are using appspot "online-hosting".
I just could not figure out how to migrate the local datastore.
As i read, one should enable datastore_admin in order to get the button to migrate the datastore in admin interface of the appserver.
How do i enable this?
I found a subdir "google_appengine_SDK_python_1.8.1/google/appengine/ext/datastore_admin/".
But I don't know how to make it available in the default admin website at "http://localhost:8080/_ah/admin".
Is there an easier way to do the migration?
Maybe a commandline tool?
You don't need to migrate the local datastore. That's just a file on disk. All the HRD logic is in the data access API in the SDK, and the dev server is already using that.

Categories

Resources