Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73946
| References | <a0d60918-2ddd-4b04-abd1-e3ce98d2e1ea@googlegroups.com> |
|---|---|
| Date | 2014-07-04 20:24 +1000 |
| Subject | Re: flask sql cann't insert Variable in VALUES |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.11485.1404469476.18130.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
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
csiph-web