I'm trying to use a MongoDB Database from a Google App Engine service is that possible? How do I install the PyMongo driver on Google App Engine? Thanks
No, it is not possible. Read the Runtime Environment section. On App Engine you'll have to use the datastore, or a 'database service' you can access using HTTP calls.
You might want to check out TyphoonAE.
It's not possible because you don't have access to networks sockets in App Engine. As long as you cannot access the database via HTTP, it's impossible.
The new runtime environment section says:
an app cannot write data to the local file system or make arbitrary network connections.
I am not sure to which level this is still being enforced (seeing that it's 7 years since the question was asked and answered), but we at Tam have successfully used the PyMongo driver in the standard Google App Engine Python runtime without issues. We simply followed the official PyMongo tutorial and it worked out.
Related
So, I am working on a project that has a backend optimization algorithm written in GAMS.
The ideal solution is to be able to use this GAMS code that is already written with the python API for GAMS. I want to be able to call this code through an HTTP request and run the algorithm, so I wanted to make a Flask server for this. Ideally, it could run in Google's App Engine, but GAMS software must be installed.
I am not sure if this is possible on App Engine, or if it can be done in a Google instance.
The data input would be from CSV's in google cloud storage and the output would be put there as well.
I was wondering if anyone has tried this before or if you know more about Google cloud and think this will or will not work. I could not find much about this online.
Your question would benefit from more detail and including references e.g. Is this GAMS?
App Engine standard is opinionated and it may not (don't know) be possible for you to bundle GAMS as part of a Python deployment to App Engine standard.
However, if you were willing to bundle a Python (Flask) server and GAMS together, it's possible you could containerize the solution and run it on App Engine flexible as a custom runtime.
Alternatives exist and may be better matches to your needs including detaching the (Flask) frontend server from the GAMS backend (?) and deploying these on App Engine (or possibly Cloud using Functions, Cloud Run, Compute Engine etc.).
Someone who has done this may be willing to provide additional pointers|guidance.
The best solution to this problem, I found, was to get rid of GAMS entirely.
There were many ways I wished to integrate this model into my web app, so I translated the model to Python using PyOMO. The performance was slightly affected, but the model can now be run in Google Cloud.
I set up the model in a Flask server and now built a REST API around it for use in the web app.
I am to develop an app, and I have to choose between Ruby on Rails or Python+Django. So far I want to do it with Ruby on Rails, because i feel more comfortable doing what I have to do on it.
But there is a problem. There would be a client app written on Python that has to communicate with mine. Cause that app should be able to communicate with mine.
First: I think if it is a matter of communicating with the MySQL database there wouldn't be an issue, cause the Python app is able to query to MySQL server with proper authentication right?
Second: and more important question: If I have a Ruby written API, to ease the queries, Could the Python app be able to invoke functions in that API and get the results? If it is possible, How could I achieve that?
Ruby on Rails 5 supports API only app, if you are using this app for APIs only, else just create a normal app and expose API endpoints that render json outputs. Use Active Record for mapping your MySql database and jbuilder for json views (both of which are available by default when you create new app). You will find lots of tutorials if you google Use Ruby on Rails as API app.
Good luck with it.. :)
I'm trying to transfer an Openshift-hosted Django website to Google App Engine. I wanted to connect it to an existing PostgreSQL database. However, I found this in Google's documentation:
A small percentage of native C python modules, and subsets of native C python modules are not available with Google App Engine. The disabled modules fall in to the following categories: (...)
Please keep in mind that third party packages which use any of the above features will not function with Google App Engine (packages such as PostgreSQL, etc).
My local GAE server produced the following error:
ImproperlyConfigured: Error loading psycopg2 module: No module named psycopg2._psycopg
Further research seems to indicate that this error was raised due to the limitations of GAE, rather than due to a configuration error. Surely there must be some reasonable way to connect my Django website with the externally hosted PostgreSQL server. What are my options?
Edit: so to clarify, I think I need a pure-Python replacement for psycopg2 that works with Django. In other words, it should also implement a Django database backend I can use.
You might be able to use pg8000.
I am looking for a simple python web framework which runs both as standalone and on Appengine.
I would like to write the app in such a way that i can switch between standalone and Appengine based on the deployment configuration. Standalone will be using RDBMS.
When i checked web.py looked simple and promising. I have the following questions:
Does web.py work well on Appengine?
Is there any major known gotchas?
Can you share your experience with using web.py on Appengine?
Any suggestions to achieve the above mentioned goal is appreciated.
Does web.py work well on Appengine?
Yes it does work pretty well, it's compact and very easy to use.
Is there any major known gotchas?
Web.py does not offer any Data Abstraction Layer compatible with GAE; that means that in order to switch from a RDBMS to a NoSQL database, you have to create by yourself a layer above both the web.db database API and the Google App Engine datastore API.
Can you share your experience with using web.py on Appengine?
I have deployed a couple of simple applications with web.py on top of GAE and other several pet projects with Sqlite as database; here a mini review.
Any suggestions to achieve the above mentioned goal is appreciated.
If the switch from Appengine to RDBMS is your primary concern, have a look to web2py.
Although with some limitations, to the best of my knowledge is the only one Python web framework GAE friendly that offers a DAL above the App Engine Datastore and other several RDBMS solutions.
Switching from one db to another is just a matter of initializing the DAL with the proper connection string:
db = DAL('sqlite://storage.db')
db = DAL('mysql://username:password#localhost/test')
db = DAL('gae')
No webapp framework on its own is going to be able to do this - the App Engine environment consists of a lot more than just a database interface and a CGI environment. Even if it could, any DAL that supports both the datastore and a relational DB is likely to sacrifice most of the flexibility of both in pursuit of that.
Your best option, if you want to take advantage of more than just the datastore, is to write your app for App Engine, and use AppScale or TyphoonAE to run your app outside the App Engine environment.
Consider using webapp2. It is similar to web.py, provides basically the same featureset, and runs outside of App Engine out-of-the-box. Besides, you get stellar compatibility with App Engine SDK and libraries (I explain it better here).
You'd only need to add a relational database library. But this is an easy choice: SQLAlqchemy is pretty much the standard in Python land, with lots of documentation and a thriving community.
I would also suggest web2py. Great framework, great community, plays out-of-the-box outside of AppEngine. It also supports a lot of databases (SQLite, PostgreSQL, MySQL, MSSQL, FireBird, Oracle, IBM DB2, Informix, Ingres, and Google App Engine).
On top of that, it's trivial to install it on Linux, Windows, Mac.
I'm building an application using Google app engine with python, and I'm stuck with making sessions. Is there any app that already does that for app engine? Thank you.
I recommend gae-sessions. The source includes demos which show how to use it, including how to integrate with the Users API or RPX/JanRain.
Disclaimer: I wrote gae-sessions, but for an informative comparison of it with alternatives, read this article.