成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁技術文章
文章詳情頁

python - 深入理解Flask 第三章代碼運行報錯, 代碼完全正常,為什么報SQL語法錯誤?

瀏覽:206日期:2022-06-29 14:18:28

問題描述

原句posts = Post.query.order_by(Post.publish_date.desc()).paginate(page, 10)

路由這里已經定義 page=1了, 作者不可能寫錯代碼啊, 我設置了utf-8編碼也不行@app.route(’/’)@app.route(’/<int:page>’)def home(page=1): posts = Post.query.order_by(Post.publish_date.desc()).paginate(page, 10) recent, top_tags = sidebar_data() return render_template(’home.html’,posts=posts,recent=recent,top_tags=top_tags )

/Library/Python/2.7/site-packages/sqlalchemy/sql/compiler.py:624: SAWarning: Can’t resolve label reference ’total DESC’; converting to text() (this warning may be suppressed after 10 occurrences) util.ellipses_string(element.element))127.0.0.1 - - [07/Jun/2017 14:44:06] 'GET / HTTP/1.1' 500 -Traceback (most recent call last): File '/Library/Python/2.7/site-packages/flask/app.py', line 1994, in __call__ return self.wsgi_app(environ, start_response) File '/Library/Python/2.7/site-packages/flask/app.py', line 1985, in wsgi_app response = self.handle_exception(e) File '/Library/Python/2.7/site-packages/flask/app.py', line 1540, in handle_exception reraise(exc_type, exc_value, tb) File '/Library/Python/2.7/site-packages/flask/app.py', line 1982, in wsgi_app response = self.full_dispatch_request() File '/Library/Python/2.7/site-packages/flask/app.py', line 1614, in full_dispatch_request rv = self.handle_user_exception(e) File '/Library/Python/2.7/site-packages/flask/app.py', line 1517, in handle_user_exception reraise(exc_type, exc_value, tb) File '/Library/Python/2.7/site-packages/flask/app.py', line 1612, in full_dispatch_request rv = self.dispatch_request() File '/Library/Python/2.7/site-packages/flask/app.py', line 1598, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File '/Users/andy/Desktop/Mastering Flask_Code Bundle/Chapter 3/chapter_3/main.py', line 114, in home top_tags=top_tags File '/Library/Python/2.7/site-packages/flask/templating.py', line 134, in render_template context, ctx.app) File '/Library/Python/2.7/site-packages/flask/templating.py', line 116, in _render rv = template.render(context) File '/Library/Python/2.7/site-packages/jinja2/environment.py', line 1008, in render return self.environment.handle_exception(exc_info, True) File '/Library/Python/2.7/site-packages/jinja2/environment.py', line 780, in handle_exception reraise(exc_type, exc_value, tb) File '/Users/andy/Desktop/Mastering Flask_Code Bundle/Chapter 3/chapter_3/templates/home.html', line 1, in top-level template code {% extends 'base.html' %} File '/Users/andy/Desktop/Mastering Flask_Code Bundle/Chapter 3/chapter_3/templates/base.html', line 45, in top-level template code {% block body %} File '/Users/andy/Desktop/Mastering Flask_Code Bundle/Chapter 3/chapter_3/templates/home.html', line 38, in block 'body' {{ render_pagination(posts, ’home’) }} File '/Library/Python/2.7/site-packages/jinja2/runtime.py', line 551, in _invoke rv = self._func(*arguments) File '/Users/andy/Desktop/Mastering Flask_Code Bundle/Chapter 3/chapter_3/templates/base.html', line 5, in template <a href='http://www.piao2010.com/wenda/{{ url_for(’home’, page=pagination.prev().page) }}' aria-label='Previous'> File '/Library/Python/2.7/site-packages/flask_sqlalchemy/__init__.py', line 338, in prev return self.query.paginate(self.page - 1, self.per_page, error_out) File '/Library/Python/2.7/site-packages/flask_sqlalchemy/__init__.py', line 475, in paginate items = self.limit(per_page).offset((page - 1) * per_page).all() File '/Library/Python/2.7/site-packages/sqlalchemy/orm/query.py', line 2703, in all return list(self) File '/Library/Python/2.7/site-packages/sqlalchemy/orm/query.py', line 2855, in __iter__ return self._execute_and_instances(context) File '/Library/Python/2.7/site-packages/sqlalchemy/orm/query.py', line 2878, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File '/Library/Python/2.7/site-packages/sqlalchemy/engine/base.py', line 945, in execute return meth(self, multiparams, params) File '/Library/Python/2.7/site-packages/sqlalchemy/sql/elements.py', line 263, in _execute_on_connection return connection._execute_clauseelement(self, multiparams, params) File '/Library/Python/2.7/site-packages/sqlalchemy/engine/base.py', line 1053, in _execute_clauseelement compiled_sql, distilled_params File '/Library/Python/2.7/site-packages/sqlalchemy/engine/base.py', line 1189, in _execute_context context) File '/Library/Python/2.7/site-packages/sqlalchemy/engine/base.py', line 1402, in _handle_dbapi_exception exc_info File '/Library/Python/2.7/site-packages/sqlalchemy/util/compat.py', line 203, in raise_from_cause reraise(type(exception), exception, tb=exc_tb, cause=cause) File '/Library/Python/2.7/site-packages/sqlalchemy/engine/base.py', line 1182, in _execute_context context) File '/Library/Python/2.7/site-packages/sqlalchemy/engine/default.py', line 470, in do_execute cursor.execute(statement, parameters) File '/Library/Python/2.7/site-packages/MySQLdb/cursors.py', line 205, in execute self.errorhandler(self, exc, value) File '/Library/Python/2.7/site-packages/MySQLdb/connections.py', line 36, in defaulterrorhandler raise errorclass, errorvalueProgrammingError: (_mysql_exceptions.ProgrammingError) (1064, 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’-10, 10’ at line 3') [SQL: u’SELECT post.id AS post_id, post.title AS post_title, post.text AS post_text, post.publish_date AS post_publish_date, post.user_id AS post_user_id nFROM post ORDER BY post.publish_date DESC n LIMIT %s, %s’] [parameters: (-10, 10)]127.0.0.1 - - [07/Jun/2017 14:44:06] 'GET /?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1' 200 -127.0.0.1 - - [07/Jun/2017 14:44:06] 'GET /?__debugger__=yes&cmd=resource&f=jquery.js HTTP/1.1' 200 -127.0.0.1 - - [07/Jun/2017 14:44:06] 'GET /?__debugger__=yes&cmd=resource&f=debugger.js HTTP/1.1' 200 -(<type ’int’>, 1)127.0.0.1 - - [07/Jun/2017 14:44:06] 'GET / HTTP/1.1' 500 -Traceback (most recent call last): File '/Library/Python/2.7/site-packages/flask/app.py', line 1994, in __call__ return self.wsgi_app(environ, start_response) File '/Library/Python/2.7/site-packages/flask/app.py', line 1985, in wsgi_app response = self.handle_exception(e) File '/Library/Python/2.7/site-packages/flask/app.py', line 1540, in handle_exception reraise(exc_type, exc_value, tb) File '/Library/Python/2.7/site-packages/flask/app.py', line 1982, in wsgi_app response = self.full_dispatch_request() File '/Library/Python/2.7/site-packages/flask/app.py', line 1614, in full_dispatch_request rv = self.handle_user_exception(e) File '/Library/Python/2.7/site-packages/flask/app.py', line 1517, in handle_user_exception reraise(exc_type, exc_value, tb) File '/Library/Python/2.7/site-packages/flask/app.py', line 1612, in full_dispatch_request rv = self.dispatch_request() File '/Library/Python/2.7/site-packages/flask/app.py', line 1598, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File '/Users/andy/Desktop/Mastering Flask_Code Bundle/Chapter 3/chapter_3/main.py', line 114, in home top_tags=top_tags File '/Library/Python/2.7/site-packages/flask/templating.py', line 134, in render_template context, ctx.app) File '/Library/Python/2.7/site-packages/flask/templating.py', line 116, in _render rv = template.render(context) File '/Library/Python/2.7/site-packages/jinja2/environment.py', line 1008, in render return self.environment.handle_exception(exc_info, True) File '/Library/Python/2.7/site-packages/jinja2/environment.py', line 780, in handle_exception reraise(exc_type, exc_value, tb) File '/Users/andy/Desktop/Mastering Flask_Code Bundle/Chapter 3/chapter_3/templates/home.html', line 1, in top-level template code {% extends 'base.html' %} File '/Users/andy/Desktop/Mastering Flask_Code Bundle/Chapter 3/chapter_3/templates/base.html', line 45, in top-level template code {% block body %} File '/Users/andy/Desktop/Mastering Flask_Code Bundle/Chapter 3/chapter_3/templates/home.html', line 38, in block 'body' {{ render_pagination(posts, ’home’) }} File '/Library/Python/2.7/site-packages/jinja2/runtime.py', line 551, in _invoke rv = self._func(*arguments) File '/Users/andy/Desktop/Mastering Flask_Code Bundle/Chapter 3/chapter_3/templates/base.html', line 5, in template <a href='http://www.piao2010.com/wenda/{{ url_for(’home’, page=pagination.prev().page) }}' aria-label='Previous'> File '/Library/Python/2.7/site-packages/flask_sqlalchemy/__init__.py', line 338, in prev return self.query.paginate(self.page - 1, self.per_page, error_out) File '/Library/Python/2.7/site-packages/flask_sqlalchemy/__init__.py', line 475, in paginate items = self.limit(per_page).offset((page - 1) * per_page).all() File '/Library/Python/2.7/site-packages/sqlalchemy/orm/query.py', line 2703, in all return list(self) File '/Library/Python/2.7/site-packages/sqlalchemy/orm/query.py', line 2855, in __iter__ return self._execute_and_instances(context) File '/Library/Python/2.7/site-packages/sqlalchemy/orm/query.py', line 2878, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File '/Library/Python/2.7/site-packages/sqlalchemy/engine/base.py', line 945, in execute return meth(self, multiparams, params) File '/Library/Python/2.7/site-packages/sqlalchemy/sql/elements.py', line 263, in _execute_on_connection return connection._execute_clauseelement(self, multiparams, params) File '/Library/Python/2.7/site-packages/sqlalchemy/engine/base.py', line 1053, in _execute_clauseelement compiled_sql, distilled_params File '/Library/Python/2.7/site-packages/sqlalchemy/engine/base.py', line 1189, in _execute_context context) File '/Library/Python/2.7/site-packages/sqlalchemy/engine/base.py', line 1402, in _handle_dbapi_exception exc_info File '/Library/Python/2.7/site-packages/sqlalchemy/util/compat.py', line 203, in raise_from_cause reraise(type(exception), exception, tb=exc_tb, cause=cause) File '/Library/Python/2.7/site-packages/sqlalchemy/engine/base.py', line 1182, in _execute_context context) File '/Library/Python/2.7/site-packages/sqlalchemy/engine/default.py', line 470, in do_execute cursor.execute(statement, parameters) File '/Library/Python/2.7/site-packages/MySQLdb/cursors.py', line 205, in execute self.errorhandler(self, exc, value) File '/Library/Python/2.7/site-packages/MySQLdb/connections.py', line 36, in defaulterrorhandler raise errorclass, errorvalueProgrammingError: (_mysql_exceptions.ProgrammingError) (1064, 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’-10, 10’ at line 3') [SQL: u’SELECT post.id AS post_id, post.title AS post_title, post.text AS post_text, post.publish_date AS post_publish_date, post.user_id AS post_user_id nFROM post ORDER BY post.publish_date DESC n LIMIT %s, %s’] [parameters: (-10, 10)]

問題解答

回答1:

看到你的sql語句

select * from 表 limit -10, 10

正確的應該是

select * from 表 limit 0, 10

你page傳入的是0吧?至少是1起始啊

回答2:

數據庫,表沒建好

標簽: Python 編程
成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久
国产精品99久久久久久久女警 | 欧美激情综合| 7777精品伊人久久久大香线蕉完整版| 日韩激情av在线| 媚黑女一区二区| 狠狠噜噜久久| 亚洲色图欧洲色图婷婷| 在线观看视频日韩| 亚洲欧洲成人自拍| 亚洲国产精品第一区二区三区| 亚洲人成在线播放网站岛国| 日韩视频久久| 亚洲自拍偷拍av| 一本色道久久综合狠狠躁的推荐| 亚洲成人免费看| 色综合久久99| 激情综合网av| 精品欧美久久久| 91日韩在线专区| 中文字幕一区二区三区色视频| 国产精品国产三级国产专区53| 成人欧美一区二区三区小说 | 妖精视频成人观看www| 一区二区三区自拍| 色噜噜偷拍精品综合在线| 精品亚洲国产成人av制服丝袜| 欧美一区二区三区日韩视频| 99在线视频精品| 中文字幕一区二| 蘑菇福利视频一区播放| 日日摸夜夜添夜夜添精品视频| 欧美在线小视频| 国产老女人精品毛片久久| 精品久久久久99| 国内精品久久久久久久果冻传媒| 一区二区免费在线播放| 在线观看成人免费视频| 国产精品亚洲专一区二区三区 | 欧美精品色综合| 波多野结衣在线一区| 欧美国产激情一区二区三区蜜月| 日韩午夜激情| 欧美aaa在线| 精品毛片乱码1区2区3区| 欧美日韩日本网| 一区二区三区精品久久久| 葵司免费一区二区三区四区五区| 狠狠色狠狠色综合| 久久久国产午夜精品| 亚洲精品在线免费| 蜜臀av性久久久久蜜臀aⅴ流畅 | 亚洲精品影视| 免播放器亚洲一区| 日韩久久久久久| 欧美精品一区三区在线观看| 一级中文字幕一区二区| 欧洲av一区二区嗯嗯嗯啊| 不卡一卡二卡三乱码免费网站| 国产精品国产三级国产有无不卡| 久久激情婷婷| 国产不卡在线一区| 亚洲天堂a在线| 精品视频在线免费观看| 91麻豆国产福利精品| 亚洲不卡av一区二区三区| 91精品久久久久久久91蜜桃| 国产精品豆花视频| 麻豆精品一区二区av白丝在线| 久久久久久久av麻豆果冻| 国产精品日韩| 国产精品99久久久久久久女警| 国产精品视频免费| 在线欧美日韩国产| 欧美国产免费| 日韩电影在线观看网站| 久久网站热最新地址| 裸体一区二区| 波多野结衣中文字幕一区| 亚洲一级电影视频| 欧美电影免费观看完整版| 国产一区二区三区久久久久久久久| 国产传媒欧美日韩成人| 亚洲精品高清在线观看| 日韩一级成人av| 国产亚洲一区在线播放| 成人国产在线观看| 水蜜桃久久夜色精品一区的特点| 久久久精品tv| 欧美日韩的一区二区| 亚洲精品一区二区三区蜜桃久| 国产精品中文字幕欧美| 亚洲人精品午夜| 日韩精品一区二区三区四区视频 | 日本韩国欧美三级| 色综合色综合色综合色综合色综合 | 国产真实乱子伦精品视频| 亚洲欧洲日韩在线| 欧美精品第1页| 日韩午夜免费视频| 成人av在线电影| 日韩国产欧美在线播放| 久久精品一区二区三区av| 91久久精品一区二区二区| 欧美日本在线| 国模套图日韩精品一区二区| 中文字幕日韩av资源站| 欧美日韩精品免费| 成人av资源下载| 色综合久久中文综合久久97 | 色偷偷一区二区三区| 麻豆91在线看| 色老头久久综合| 91丨九色丨国产丨porny| 日本亚洲欧美天堂免费| 国产精品福利在线播放| 日韩一区二区三区免费看| 久久国产一区二区| 精品91久久久久| 国产剧情一区二区| 午夜精品久久久久影视| 国产精品拍天天在线| 91精品久久久久久蜜臀| 一本久久精品一区二区| 亚洲欧洲一区二区天堂久久| 午夜伊人狠狠久久| 亚洲天堂中文字幕| 久久亚洲一级片| 欧美日韩国产一区二区三区地区| 国产欧美午夜| 欧美三级免费| 成人福利视频网站| 精品一区二区三区在线播放视频 | 香蕉亚洲视频| 亚洲福利一区| 欧美.日韩.国产.一区.二区| 国产suv精品一区二区883| 久久精品国产**网站演员| 亚洲国产日韩a在线播放性色| 亚洲色图视频网站| 国产欧美日韩视频在线观看| 欧美一级二级在线观看| 欧美日韩一本到| 在线免费观看成人短视频| 亚洲综合社区| 国产麻豆综合| 国产精品视频| 国产欧美日韩亚洲| 亚洲国产精品第一区二区| 国产在线成人| 欧美日本不卡高清| 色综合天天综合色综合av| 99视频有精品| av电影在线观看完整版一区二区 | 亚洲一区三区电影在线观看| 亚洲精品国产日韩| 国内精品久久久久久久97牛牛| 欧美淫片网站| 欧美黄色大片网站| 91蜜桃传媒精品久久久一区二区| 暴力调教一区二区三区| 国产成a人无v码亚洲福利| 国产伦精品一区二区三区视频青涩| 美女网站在线免费欧美精品| 蜜臀精品久久久久久蜜臀| 天天射综合影视| 性感美女久久精品| 天天色图综合网| 日本女优在线视频一区二区 | 国产大片一区二区| 国产成人精品亚洲777人妖| 国产精品 欧美精品| 国产福利精品一区| 国产成人免费视频一区| 国产一区二区三区免费在线观看| 精品一区二区av| 国产乱码精品一区二区三区忘忧草 | 欧美视频一二三区| 欧美丝袜丝交足nylons图片| 欧美视频一区二区| 欧美二区三区91| 日韩欧美视频在线| 亚洲精品在线三区| 国产亚洲一区二区三区四区 | 在线免费观看成人短视频| 欧洲精品一区二区| 9191久久久久久久久久久| 欧美一级黄色大片| 国产日韩影视精品| 中文字幕佐山爱一区二区免费| 亚洲美女视频在线观看| 亚洲国产三级在线| 麻豆精品国产91久久久久久| 国产精品一区在线观看你懂的| 国产精品888| 99在线精品免费| 亚洲黄色一区二区三区| 久久成人资源| 欧美丰满一区二区免费视频| 26uuu精品一区二区三区四区在线| 国产午夜精品久久|