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


Groups > comp.lang.python > #36539

Re: Psycopg2 SyntaxError: invalid syntax on "INSERT INTO" database

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin.stu.neva.ru!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <msirenef@lightbird.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'syntax': 0.03; 'skip:a 60': 0.05; 'sys': 0.05; '"__main__":': 0.07; '__name__': 0.07; 'extracted': 0.07; 'main()': 0.07; 'python': 0.09; 'cursor': 0.09; 'follows.': 0.09; 'interval,': 0.09; 'python:': 0.09; 'cc:addr :python-list': 0.10; 'def': 0.10; '%s,': 0.16; "'localhost',": 0.16; '(%s,': 0.16; 'char,': 0.16; 'main():': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'simplified': 0.16; 'syntaxerror:': 0.16; 'wrote:': 0.17; 'element': 0.17; 'exists': 0.17; 'version.': 0.17; 'jan': 0.18; 'import': 0.21; 'cc:2**0': 0.23; 'work.': 0.23; 'cc:no real name:2**0': 0.24; 'host': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'values': 0.26; 'skip:# 10': 0.27; 'actual': 0.28; 'key,': 0.29; 'error': 0.30; 'primary': 0.30; 'code': 0.31; 'file': 0.32; 'problem': 0.33; 'code:': 0.33; 'thanks': 0.34; 'table': 0.35; 'but': 0.36; 'subject:" ': 0.36; 'subject:: ': 0.38; 'some': 0.38; 'received:192': 0.39; 'skip:" 10': 0.40; 'received:192.168': 0.40; 'help': 0.40; 'your': 0.60; 'skip:u 10': 0.60; 'email addr:gmail.com': 0.63; 'serial': 0.66; '(id': 0.84; '2013': 0.84; 'actually,': 0.84; 'saj': 0.84
Date Wed, 09 Jan 2013 20:07:22 -0500
From Mitya Sirenef <msirenef@lightbird.net>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1
MIME-Version 1.0
To andydtaylor@gmail.com
Subject Re: Psycopg2 SyntaxError: invalid syntax on "INSERT INTO" database
References <b1c7ea47-47b4-4784-8037-e0856fdaa7cd@googlegroups.com> <kcl0p4$ssr$1@reader1.panix.com> <bd7fc6c9-a1d0-4bb0-91cc-435eda94154e@googlegroups.com>
In-Reply-To <bd7fc6c9-a1d0-4bb0-91cc-435eda94154e@googlegroups.com>
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
Cc python-list@python.org
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 <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.351.1357780055.2939.python-list@python.org> (permalink)
Lines 49
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1357780055 news.xs4all.nl 6854 [2001:888:2000:d::a6]:52036
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:36539

Show key headers only | View raw


On Wed 09 Jan 2013 07:19:10 PM EST, andydtaylor@gmail.com wrote:
> Hi John,
>
> He're the code I would like to see work. The cursor_to is an oversight. I extracted this element from some other code in an attempt to isolate/resolve the problem myself, hence having a simplified table version. Which works actually, but unfortunately that's not educating me suffieciently. Actual error message I see follows.
>
> - - - - - - - - - - - - - - - - - - - - - - - - -
> Code:
>
> #!/usr/bin/python
> import psycopg2
> import sys
>
> def main():
>     db = psycopg2.connect(
>        host = 'localhost',
>        database = 'gisdb',
>        user = 'postgres',
>        password = '######'
>     )
>     cursor = db.cursor()
>     cursor.execute("DROP TABLE IF EXISTS tubecross")
>     cursor.execute("CREATE TABLE tubecross (id serial PRIMARY KEY, station_code char, SAJ interval, SPB interval, SOQ interval);")
>     cursor.execute("INSERT INTO tubecross (station_code, SAJ, SPB, SOQ) VALUES (%s, %s, %s, %s)",(SAJ, 00:00, 00:22, 00:27))
>     db.commit()
>
> if __name__ == "__main__":
> 	main()
>
> - - - - - - - - - - - - - - - - - - - - - - - - -
> Error Message:
>
> andyt@andyt-ThinkPad-X61:~/projects/django-stringer/Other/TFLJPAPI$ python creat_db_exp.py
>    File "creat_db_exp.py", line 15
>      cursor.execute("INSERT INTO tubecross (station_code, SAJ, SPB, SOQ) VALUES (%s, %s, %s, %s)",(SAJ, 00:00, 00:22, 00:27))
>                                                                                                           ^
> SyntaxError: invalid syntax
>
>
> Thanks for your help


00:00 etc are not quoted?

 - mitya



--
Lark's Tongue Guide to Python: http://lightbird.net/larks/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Psycopg2 SyntaxError: invalid syntax on "INSERT INTO" database andydtaylor@gmail.com - 2013-01-09 15:52 -0800
  Re: Psycopg2 SyntaxError: invalid syntax on "INSERT INTO" database John Gordon <gordon@panix.com> - 2013-01-10 00:08 +0000
    Re: Psycopg2 SyntaxError: invalid syntax on "INSERT INTO" database andydtaylor@gmail.com - 2013-01-09 16:19 -0800
      Re: Psycopg2 SyntaxError: invalid syntax on "INSERT INTO" database Mitya Sirenef <msirenef@lightbird.net> - 2013-01-09 20:07 -0500
      Re: Psycopg2 SyntaxError: invalid syntax on "INSERT INTO" database MRAB <python@mrabarnett.plus.com> - 2013-01-10 01:11 +0000
        Re: Psycopg2 SyntaxError: invalid syntax on "INSERT INTO" database andydtaylor@gmail.com - 2013-01-09 18:20 -0800
          Re: Psycopg2 SyntaxError: invalid syntax on "INSERT INTO" database Mitya Sirenef <msirenef@lightbird.net> - 2013-01-09 21:56 -0500
        Re: Psycopg2 SyntaxError: invalid syntax on "INSERT INTO" database andydtaylor@gmail.com - 2013-01-09 18:20 -0800
  How to run multiline shell command within python Karim <kliateni@gmail.com> - 2013-01-10 07:01 +0100
  Re: [Tutor] How to run multiline shell command within python Hugo Arts <hugo.yoshi@gmail.com> - 2013-01-10 09:31 +0100
  Re: [Tutor] How to run multiline shell command within python Karim <kliateni@gmail.com> - 2013-01-10 15:25 +0100
  Re: [Tutor] How to run multiline shell command within python Matty Sarro <msarro@gmail.com> - 2013-01-10 10:21 -0500
  Re: [Tutor] How to run multiline shell command within python Karim <kliateni@gmail.com> - 2013-01-10 20:07 +0100

csiph-web