1

I'm running the following code with web.py to get mysql data and print it out on a webpage. For some reason, when I query the webpage, I get just the word "None". Any idea what the problem is? There is some data in the MySQL database, the credentials are valid, and the code is running without any errors.

import web
import MySQLdb
import json
import collections

db=MySQLdb.connect(user="someuser",
                  passwd="somepass",db="somedatabase")

urls = (
        '/', 'index',
        '/test', 'test'
)


class index:
        def GET(self):
                c=db.cursor()
                c.execute("""
            SELECT email, password
            FROM users
            """)

                rows = c.fetchall()

Screenshot

1 Answer 1

2

I think your code fragment may be either incomplete or misformatted, but assuming it is not, the GET method has no return statement, which means that any invocation would return None, which in turn would be rendered as the string "None"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.