小编Cat*_*Cat的帖子

如果MySQL没有返回结果,则打印

到目前为止,这是我的代码。No results found如果MySQL没有返回结果,我正在尝试打印,但是我无法弄清楚。也许我使用了不正确的参数。谁能给我一个例子?非常感激!

def movie_function(film):
    connection = mysql connection info
    cursor = connection.cursor()
    sql = "SELECT * FROM film_database WHERE film_name = '"+film+"' ORDER BY actor"

    cursor.execute(sql)
    rows = cursor.fetchall()
    for row in rows:
        print row[1]
Run Code Online (Sandbox Code Playgroud)

python mysql python-2.7

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

mysql ×1

python ×1

python-2.7 ×1