[Tutor] Why this error ?

John Fouhy john at fouhy.net
Thu Feb 1 00:22:37 CET 2007


On 01/02/07, Mário Gamito <gamito at gmail.com> wrote:
> 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")'
> "

Your indentation is wrong.  Try outdenting all your code so it all
starts in the same column, and see if that helps.

-- 
John.


More information about the Tutor mailing list