[Tutor] Why this error ?

Eric Pais eric at digitalert.net
Thu Feb 1 03:13:12 CET 2007


Danny Yoo wrote:
>>> I mean put all the parameters with quotes, I guess that might be a cause
>>> of the error.
>>>
>>> conn = MySQLdb.connect ('host' = "localhost", 'user' = "testuser",
>>> 'passwd'= "testpass", 'db' = "test")
>>>       
>> No, unfortunately the problem remains, but thanks anyway.
>>     
>
>
> It's supposed to be without quotes on the keyword argument names.
>
>      conn = MySQLdb.connect (host = "localhost",
>                              user = "testuser",
>                              passwd = "testpass",
>                              db = "test")
>
> It is very good that you're showing us literal error messages.  There is 
> something very funky looking in the error message you're showing us:
>
>      "./mysql.py: line 3: syntax error near unexpected token `(
>
> That does NOT look like a Python error message.  It looks like a shell 
> error message from bash.  Double check that you're running the script with 
> Python.
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
>   
Read what Danny Yoo said.

You are executing the file with

"./mysql.py" If you don't have the file starting with a shebang #! the script will be executed as a shell script, and not via python.

try putting this on the first line

#!/usr/bin/env python



More information about the Tutor mailing list