Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #73946

Re: flask sql cann't insert Variable in VALUES

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.075
X-Spam-Evidence '*H*': 0.85; '*S*': 0.00; 'python.': 0.02; 'insert': 0.05; 'cc:addr:python-list': 0.11; 'def': 0.12; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'overloaded': 0.16; 'sorts': 0.16; 'stake': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'error': 0.23; 'tells': 0.24; 'cc:2**0': 0.24; 'second': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'errors': 0.30; 'nature': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; "they'll": 0.31; 'username': 0.31; 'know.': 0.32; 'text': 0.33; 'fri,': 0.33; 'actual': 0.34; 'table': 0.34; 'basic': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'should': 0.36; 'error.': 0.37; 'wrong': 0.37; 'two': 0.37; 'server': 0.38; 'pm,': 0.38; 'rather': 0.38; 'explain': 0.39; 'sure': 0.39; 'unable': 0.39; 'either': 0.39; 'logs': 0.60; 'simply': 0.61; 'first': 0.61; 'you.': 0.62; 'complete': 0.62; 'show': 0.63; 'more': 0.64; 'here': 0.66; 'frank': 0.68; 'request.': 0.70; 'jul': 0.74; 'absolutely': 0.87; 'error;': 0.91; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=fIXUwKkFZAdXkIGO9YwCLBaNdIn8KuBslSZqTH6A184=; b=HMws2qgx66JRZcCnwC18WxXBWzHdSQ0Wc0y5H5RhEBajIbIJmJYEiNDRV6In9AZ6mM P4X/LeQPZFXxFWEndOSZjeuOFrfmMA2Yn4jV5932FoHigh3lG/b+8WhXaHax5wkmGcYt UeoLAkHaVZXwcAvKdWteomjCEDPy3yxMibITk/TTmmwS2ugIcKJnyZvXem8XBrjr41aW zC5FbBMrhLbq84s2SHBZEnscHgT8j8rjdL8ojXg4uBy4JH1gPJ1vGk51nrypDeZe5WNr 7qlVmN1E3afyb6vgwxzLKCVQIkBeqNaAX3PfIJ+hxzg1fR0bop5Xt/2dovZf9/U3nOa5 cAlw==
MIME-Version 1.0
X-Received by 10.52.172.5 with SMTP id ay5mr1007333vdc.38.1404469467034; Fri, 04 Jul 2014 03:24:27 -0700 (PDT)
In-Reply-To <a0d60918-2ddd-4b04-abd1-e3ce98d2e1ea@googlegroups.com>
References <a0d60918-2ddd-4b04-abd1-e3ce98d2e1ea@googlegroups.com>
Date Fri, 4 Jul 2014 20:24:26 +1000
Subject Re: flask sql cann't insert Variable in VALUES
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.11485.1404469476.18130.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1404469476 news.xs4all.nl 2837 [2001:888:2000:d::a6]:38802
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:73946

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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