Re: flask sql cann't insert Variable in VALUES

2014-07-06 Thread Frank Liou
Thank you CA 

learn so much from your words
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: flask sql cann't insert Variable in VALUES

2014-07-04 Thread Chris Angelico
On Fri, Jul 4, 2014 at 8:15 PM, Frank Liou  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
-- 
https://mail.python.org/mailman/listinfo/python-list