I am trying to access one Django Project Database value from another Django Project. So far I have tried making REST API on both the applications and it is working somewhat well on the local server. However, I am concerned that when I will be deploying both the projects on the server it will create some lag to access over the API. Moreover, if one server/application is down for maintenance, the other will be inaccessible.
Is it possible to directly access the other app database without using API as it will be much more faster and reliable?
Thanks.
Related
We are currently building our event management platform at a company i work for, The authentication service is being built with ASP.NET identity framework.
The main event management platform is built in Django using python, which i have built.
We are also planning on building a custom admin portal in ASP.NET MVC,
which will manage users and event data.
The problem is that the C# guys(Who are contractors albeit very experienced developers) want to build out the API using ASP.NET for the event app which is built in django, using the Database first model that .NET provides, thus the database migrations will be handled by Django, but the actual API will be built using ASP.NETS Web API, directly from the database.
This approach does not seem to make much sense in my opinion as it would make a lot more sense to build out the the API using Django rest framework and manage the database migrations for the event app. Instead of tightly coupling the database with Web API.
Either way both approaches are are effectively doing the same thing, but i don't think it's efficient to constantly manage two environments, migrations in one environment and api management in the other, this does not allow for flexibility.
What are the potential disadvantages of the WEB API approach.
I have a Django application that integrates data from a SQL database and displays that as a downloadable HTML table. Now I would also like to add analysis functionality, but instead of painstakingly adding only a few functionalities using JavaScript, I want to redirect the user to a Jupyter notebook, so the user has full access to the functionality of Python data analysis libraries or even other languages. Now I'm not sure how to approach this and I have several questions:
Am I right that Jupyter needs to be run on a different server than the Django app since it uses the Tornado server?
How would I transfer the data produced with Django to Jupyter? I store the data in a new MySQL table, but I would at least need to transfer the table name.
Given the table name was transferred to Jupyter I would still need to execute custom code to access the database. I found in this question that some defaults for code execution can be set in IPython configuration, but since the table from which the data should be loaded is never the same, this would have to be adapted dynamically.
I'm glad for any suggestions and comments on whether this idea makes sense at all.
Am I right that Jupyter needs to be run on a different server than the Django app since it uses the Tornado server?
No. They can run on the same server.
How would I transfer the data produced with Django to Jupyter? I store the data in a new MySQL table, but I would at least need to transfer the table name.
You can run django and Jupyter together and execute any django code from Jupyter. The easiest way to do so is by using shell_plus from the package django-extensions You can even connect to the production database.
You should consider the possible security and data safety risks. This is a potential vector for remote code execution and data leaks.
It's probably safer to spin up a cloned django instance with a cloned database or use a different django configuration (settings.py) with read-only access to the db.
It's quite easy to mess up production data from Jupyter, since you can do stuff such as User.objects.all().delete() And that would be a problem...
Also consider running this as a user with stricter read and write permissions than you use for your regular django app.
And of course, you should make sure that the Jupyter site is not exposed on a publicly accessible url.
I've recently started my python/django walkthrough and there's still a question that bothers me: I dont find a really easy, unobtrusive, painless way to deploy a Django app =(. I only see tutorials of mod_python, fastCGI, wsgi stuff - all of them are necessary for each webapp I create..
I'm used to Java web-apps (JSF+Tomcat) and I'm used to just drop the *war package in the webapps folder. Or uploading the *war through tomcat-manager. Or, even better, make a maven-hot-remote-deploy. And as far as I'm concerned, simple PHP apps also need minimum config (after setting up the apache2 conf, just cp the php-webapp-folder to /var/www/ would do..). I cant believe that Python lacks this kind of feature =((
My point is: after a clean OS install (let's take a JEE-VPS for example), I only need do setup my web server once. If I develop the webapp01, I choose one of the options above to deploy it. When I develop my webapp02, the same thing - no need to change tomcat-some-conf.xml to deploy it after webapp01. Obviously I consider only small webapps, like Django admin ones. =]
My target is to setup a Python/Django webserver and dynamically create Django admin webapp's, automatically hot deploying them to the webserver. So, I'd initially setup the web server stuff once and have a ready http://myserver.com. When user A generated a webappA01, it would be transparently available in http://myserver.com/userA/webappA01.
Is it possible?
Modern approach is to use uwsgi with Apache or NGINX (I recommend this one).
I don't know a tool which will auto-deploy your Django app. There are many web services like Heroku which deploy your app automatically (you supply just your VCS repository).
You can deploy your Django app semi-automatically by writing some scripts that will sync your code base, apply migrations for the db and reload web server. Check fabric or Buildbot.
First, Python/Django does not provide a "drop-in" deploy function by themselves, nor I know any way of doing something similar to war packages.
There are services that provide easy deploy methods like Heroku, but I recommend reading Django's official documentation about deploying for starters.
My target is to setup a Python/Django webserver and dynamically create
Django admin webapp's, automatically hot deploying them to the
webserver. So, I'd initially setup the web server stuff once and have
a ready http://myserver.com. When user A generated a webappA01, it
would be transparently available in
http://myserver.com/userA/webappA01.
Sounds like what you want to do can be accomplished with custom AdminSite instances.
Basically, you can write a view that instantiates an AdminSite instance named "webapp" (you can pull those parameters from the url of course, and check if the webapp data exists on the database). You'll need to connect any models you want to that AdminSite instance either from that view or by overriding its init method. The autodiscover function of the Django admin may not work for custom admin sites.
I am looking for feasible solutions for my Application to be backed with MongoDB. I am looking to host the MongoDB on the cloud with a python based server to interact with the DB and my app (either mobile/web). I am trying to understand how the architecture should look like.
Either i can host a mongoDB on the AWS cloud and have the server running there only.
I also tried using MongoLab and seemed to be simple accessing it using HTTP requests. but i am not sure if it exposes all the essential features of MongoDB (what ever i can do using a pymongo driver)? Also, should i go for accessing the MongoLab service directly from my application or still i should build a server in-between?
I would prefer to building an server in either case as i want to do some processing before sending the data back to application. but i am not sure in that case how my DB-server-app interaction design should be
Any suggestions?
One thing to consider is that you don't need to use MongoLab's REST API. You can connect directly via a driver as well.
So, if you need to implement business logic (which it sounds like you do), it makes sense to have a three tier architecture with an app server connecting to your MongoLab database via one of the drivers. In your case it sounds like this would be pymongo.
-will
In order to redeploy a GAE application, I currently have to install the GAE deployment tools on the system that I am using for deployment. While this process is relatively straight forward, the deployment process is a manual process that does not work from behind a firewall and the deployment tools must be installed on every machine that will be used for updating GAE apps. A more ideal solution would be if I could update a GAE application from another GAE application that I have deployed previously. This would remove the need to have multiple systems configured to deploy apps.
Since the GAE deployment tools are written in Python and the GAE App Engine supports Python, is it possible to modify appcfg.py to work from within GAE? The use case would be to pull a project from GitHub or some other online repository and update one GAE application from another GAE app. If this is not possible, what is the limiting constraint?
Is it possible? Yes. The protocol appcfg uses to update apps is entirely HTTP-based, so there's absolutely no reason you couldn't write an app that's capable of deploying other apps (or redeploying itself - self-modifying code)! You may even be able to reuse large parts of appcfg.py to do it.
Is it easy? Probably not. It's quite likely you'll need to understand a decent chunk of appcfg's internals, and the RPCs it uses to upload new apps - not a trivial undertaking. You'll also need to store your credentials in the app, in all likelihood - though you can use a role account that is and admin only for the apps it's deploying to minimize risk there.
One limiting constraint could be the protocol that the python sdk uses to communicate with the GAE servers. If it only uses HTTP, you might be OK. but if it's anything else, you might be out of luck because you can't open a socket directly from within GAE.
What problem did you have by trying to update behind a firewall?
I've got some, but finally I manage to work around them.
About your question, the constraint is that you cannot write files into a GAE app, so even though you could possibly pull from the VCS you can't write those pulled files.
So you would have to update from outside the GAE in first place.
Anyway every machine that needs to update the GAE should have the SDK anyway just to see if they changes work.
So, If you really want to do this you have two alternatives:
Host your own "updater" site and istall the SDK there, then when you want to update log into your side ( or run a script ) and do the remote update.
Although I don't know Amazon EC2 well, I think you can do pretty much the same thing as op 1 from there.
Finally I think the password to update has to be typed always. ( you could have the SDK of the App engine and modify that, because it is open source )