Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73945 > unrolled thread
| Started by | Frank Liou <fk26541598fk@gmail.com> |
|---|---|
| First post | 2014-07-04 03:15 -0700 |
| Last post | 2014-07-06 19:18 -0700 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.python
flask sql cann't insert Variable in VALUES Frank Liou <fk26541598fk@gmail.com> - 2014-07-04 03:15 -0700
Re: flask sql cann't insert Variable in VALUES Chris Angelico <rosuav@gmail.com> - 2014-07-04 20:24 +1000
Re: flask sql cann't insert Variable in VALUES Frank Liou <fk26541598fk@gmail.com> - 2014-07-06 19:18 -0700
| From | Frank Liou <fk26541598fk@gmail.com> |
|---|---|
| Date | 2014-07-04 03:15 -0700 |
| Subject | flask sql cann't insert Variable in VALUES |
| Message-ID | <a0d60918-2ddd-4b04-abd1-e3ce98d2e1ea@googlegroups.com> |
I try to insert username in to my table
it show
Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
it maybe mean no request
i try to change username to '123123'
then it works....
what's problem with this?
@app.route('/user/<username>',methods=['GET','POST'])
def hello(username):
if request.method=='POST':
save_friends(username)
return username
def save_friends(username):
conn = engine.connect()
conn.execute("INSERT INTO friends(name) VALUES(username)")
[toc] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-07-04 20:24 +1000 |
| Message-ID | <mailman.11485.1404469476.18130.python-list@python.org> |
| In reply to | #73945 |
On Fri, Jul 4, 2014 at 8:15 PM, Frank Liou <fk26541598fk@gmail.com> wrote:
> I try to insert username in to my table
>
> it show
>
> Internal Server Error
> The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
>
> ...
> def save_friends(username):
> conn = engine.connect()
> conn.execute("INSERT INTO friends(name) VALUES(username)")
There are two things that you need to understand here, and rather than
give you the answers, I'm going to point you toward what you should
know. The first one is that your result page simply tells you that
there was an error; you need to look in the server logs to find the
actual text of the error. Get to know those logs; they'll collect all
sorts of errors for you. And the second is about the nature of SQL and
Python. Have a look at the basic documentation on parameterized
queries, and *be sure you understand it*. There is a lot more at stake
here than you might realize, so I'm not simply going to explain what's
wrong here; you absolutely must comprehend parameterized queries.
ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Frank Liou <fk26541598fk@gmail.com> |
|---|---|
| Date | 2014-07-06 19:18 -0700 |
| Message-ID | <2243f87c-78d2-4503-97fa-e30f61c842e5@googlegroups.com> |
| In reply to | #73946 |
Thank you CA learn so much from your words
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web