In <b1c7ea47-47b4-4784-8037-e0856fdaa...@googlegroups.com> 
andydtay...@gmail.com writes:

> I'm a bit stuck on this "INSERT INTO" syntax error. I have no idea why it's

What syntax error?  It's always helpful if you can post the actual error
message.

> not working actually... I've tried changing column types to char but that
> didn't work. I've gone a bit blind looking at it, but hopefully you can set
> me right. With the '#'d out lines instead the file does work.

> #!/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_to.execute("CREATE TABLE tubecross (id serial PRIMARY KEY, 
> station_code char, SAJ interval, SPB interval, SOQ interval);")
>    #cursor.execute("CREATE TABLE tubecross (id serial PRIMARY KEY, num 
> integer, data varchar);")
>    #cursor.execute("INSERT INTO tubecross (num, data) VALUES (%s, %s)",(900, 
> "9abc'def"))
>    cursor_to.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()

You appear to have two very different versions of the tubecross table.
One version has three fields (id, num, data) and the other version has at
least four (station_code, SAJ, SPB, SOQ).  Which one is correct?

Also, what is the 'cursor_to' variable?  It doesn't appear to be defined
anywhere.

-- 
John Gordon                   A is for Amy, who fell down the stairs
gor...@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to