I am developing an app on Google App Engine (SDK version 1.7.0 on Windows) that I need to test often, and this testing involves a lot of GQL queries on the datastore.
You can run GQL queries at the browser in App Engine's admin interface online:
But this seems to be not possible on the SDK admin console on localhost. There is no such option:
So it seems I can run GQL queries only through python scripts on my localhost.
It's not convenient to write a python script every time to query the results for short tasks here and there. Also, if you do it at the online admin interface, you can see the query results immediately in a nice table below. If you want to visualize all your query results in a browser window through a python script you'd have to write a lot more code, basically trying to rewrite what Google has already done very well at their server admin interface.
So I am stuck having to do this at the browser on the App Engine admin interface after deployment, which keeps adding to my allowed operations count until I have soon hit my free daily quota limit.
So isn't there any way to run GQL queries (non-programmatically, on a browser) on my localhost?
You have the Interactive Console for that, you get run GQL query there.
For example you can run following code in the Interactive Console:
from google.appengine.ext import db
q = db.GqlQuery("SELECT * FROM Song WHERE composer = 'Lennon, John'")
Related
i have developed a Django web application for a chatbot that acts as s store's customers service.
At first i was using Sqlite3 foe my databases, i was working fine but some times it causes the (Data Base is Locked error).So, i switch to Mysql for the application backend and the other databases.
to be clear i have 5 DB all are under the user eman_saad:
1.db.
2.chating_log.
3.female_brain.
4.male_brain.
5.orderss.
But now i have this error:
django.db.utils.OperationalError: (1203, "User eman_saad already has more than 'max_user_connections' active connections")
i'ev tired increasing the max_connection using the terminal and login mysql>.
but still the error remain the same.
PS: I am using django10, Python3.5,webfaction shared server,Mysql
i'ev developed a chatbot web application using Django and python3 on web faction server. Basically the chatbot interacts with a store's users as a customer server.It uses the REST API to POST the user input and GET to display the chatbot output and a python file to process the input and find the output.
How the chatting works:
1. chatboy.js: it first POST the user input in the API then run the python file chabot.py.
2. chabot.py: a python file that connects to the Django backend db.sqlite3 and the conversation.sqlite3. So it select the user input from db.sqlite3 then select the matching output in the conversation.sqlite3. Finally the file will update the chatbot output in the db.sqlite3.
3. chatboy.js: will GET the last chatbot output and display it.
In development stage when i was testing the application in my local server everything works fine but problems came we i deployed the Django project in the internet. Mostly and the main ERORR that stops the application form working is :
The database is locked
I did many research and found out that:
sqlite3 is not for production and only for small or stand alone application.
sqlite3 have a multiple threads problem.
not good for realtime chatting application.
Some suggestion said either
switch all the sqlite3 to Mysql ( but how? and how i can change the sql queries in the python file to fit Mysql)
use a fast key value store like Reddis ( does it mean to make it the backend db form my project or juts the conversation.sqlite3?)
please help me because it is very frustrating and i had this error for a long time and i couldn't found and solution for the problem.
thank you,
PS: i'm using Django 10 , python3 , sqlite3, web faction server
You only need to update your settings file to change the DATABASES setting from sqlite3 to mysql or postgresql. But before you do that you will need to create a database in your Webfaction Control Panel (more information here).
I've set up a Google Cloud BigTable cluster on my project. The main codebase for the project runs within a standard Python App Engine environment, which can't use the gcloud-python library because of the reliance on grpcio. To get around this, I've set up a Python App Engine Flexible Environment service within the same project and written a very simple Flask server to run on it, which I can then hit from my standard environment. The code looks something like this:
from gcloud import bigtable
app = Flask(__name__)
client = bigtable.Client(project=bigtable_config.PROJECT_ID, read_only=True)
cluster = client.cluster(bigtable_config.ZONE_ID, bigtable_config.CLUSTER_ID)
table = cluster.table(bigtable_config.TABLE_ID)
#app.route("/query/<start_key>/<end_key>")
def run_query(start_key, end_key):
if not client.is_started():
client.start()
row_data = table.read_rows(start_key=start_key, end_key=end_key)
row_data.consume_all()
// do some stuff to the row data here, get results
return jsonify(results)
I can run this code locally and it works great. I can deploy it to my service and it continues to work great. However, if the service sits idle for some period of time (I've typically noticed it after about an hour), then every request I make starts failing with this error:
NetworkError(code=StatusCode.UNAUTHENTICATED, details="Request had invalid authentication credentials.")
If I redeploy the service, it starts working again. I do not observe this behavior when I'm running the service locally.
What am I doing wrong? I'm assuming I'm making some mistake in my setup of the client, where it's not properly using the app engine credentials. Do I need to kill the client and restart it when I encounter this error?
This issue is being tracked at github.
I'm currently working on a django application. I can't add an element to my database on the admin view. I fill all the information but when I click on save button but the operation doesn't finish and I get a timeout. I use sqlite3 as database.
My question is there any one that know the origin of this problem. If not how could I investigate the problem. When I worked with other language (Java, C ...etc) when I have a problem I can use a debugger. What are the options I have?
This Problem can occur because of following reasons:
(Less Probable) You computation code is too Slow: Which is a rarity because the Timeout is set to about 1 minute or so, and code doesn't take that time to Execute
Your app is waiting on some external resource but it is not Responding. For this you will have to check for the Django logs and check if some external resource error is there
(Most Probable) Database taking too much time: This can occur either because:
App can't connect to Database: For this you have to check database logs OR try and connect manually with database through python manage.py dbshell
DB Query Taking so much time to execute: You can test this by checking database logs for how much time a query is taking OR you can connect manually via dbshell and make the same query there
Your can also use tools Like django-profiler , Django debug toolbar etc for debugging purposes. and for native python code python debugger
I'm aiming to apply the skills to hosting an app on Heroku with Python + SQLAlchemy + Xeround + Redis/Memcache.
What is the minimal software stack that I need? I'm looking at the following:
Python
A web application framework, like Flask
MySQL
MySQLdb <-- do I need this?
SQLAlchemy
It's obvious from the question that I do not know anything about SQL yet, that it would be preposterous to look at SQLAlchemy already. That's fine. I'm planning to learn the basics then immediately apply them using a Python API, if "immediately" is possible at all.
What I have accomplished so far
For an idea of where I stand:
Hosted an app on Google App Engine, using my own custom Models and Propertys for the datastore, memcache, task queue.
Hosted an app on Heroku, but I haven't used a database with it yet.
What I'm aiming for with this question
I want to know the software stack that I need to begin using MySQL. I just want to avoid installing stuff that I don't need.
For MySQL on Heroku, I suggest https://addons.heroku.com/cleardb