[Tutor] Why this error ?
Alan Wardroper
python at wardroper.org
Thu Feb 1 10:01:38 CET 2007
Other than outdenting the whole thing, are you using a 'non-standard'
character set? Are you sure that '(' isn't an alternative encoding
variant that python isn't recognising as a parenthesis? I've see nthat
sometimes with Japanese or unicode encoding.
Just a thought...
(Just to check, I tried your code in ERIC and it ran fine for me once
the indenting was fixed up)
> I have this code:
>
> import MySQLdb
>
> conn = MySQLdb.connect (host = "localhost", user = "testuser",
> passwd = "testpass", db = "test")
> cursor = conn.cursor ()
> cursor.execute ("SELECT VERSION()")
> row = cursor.fetchone ()
> print "server version:", row[0]
> cursor.close ()
> conn.close ()
>
> that gives me the error:
> "./mysql.py: line 3: syntax error near unexpected token `('
> ./mysql.py: line 3: ` conn = MySQLdb.connect (host = "localhost", user
> = "testuser", passwd = "testpass", db = "test")'
More information about the Tutor
mailing list