Answer the question
In order to leave comments, you need to log in
Python: web print not working
I am a beginner, but in general the task is extremely simple: display the results of the query. It would seem that there are no problems. Just in case, I opened Google, everything is just as simple:
import MySQLdb
def index():
try:
con = MySQLdb.connect(host="localhost", user="###", passwd="###", db="counter")
cur = con.cursor()
cur.execute("SET NAMES `utf8`")
cur.execute("SELECT count(*) as `count`, DATE(`date`) as `date` FROM `count` WHERE `type` = 'server' GROUP BY DATE(`date`)")
result = cur.fetchall()
for row in result:
print(row)
except MySQLdb.Error:
print(db.error())
print "Hello world"
Answer the question
In order to leave comments, you need to log in
Votonoche ... And what is "from the browser" do not specify? I suspect that print will not help you here.
There is something like this in the log,
[Mon Nov 12 12:31:50 2012] [error] [client 93.91.12.20] mod_python.publisher: nothing to publish.
what could it mean? I'm dealing with python under the web for the first time, so sorry for stupid questions
In theory, print will output the result to your server's stdout. But for the web, it's better to use logging (if this is a real application):
import logging
logging.info('Your message there')
I am more than sure that it is necessary to return data using the yield method
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question