Error connecting to MySQL from Python
Carlos Ortiz
carlos.ortiz.asm at gmail.com
Sat Oct 12 13:18:06 EDT 2013
On Saturday, October 12, 2013 11:46:49 AM UTC-5, Jussi Piitulainen wrote:
> carlos.o... at gmail.com writes:
>
>
>
> > So I wrote my method like this:
>
> ...
>
> > cnxOMC = mysql.connector.connect(user,
>
> > password,
>
> > 'localhost',
>
> > database)
>
> ...
>
> > the following code executes nice and smooth:
>
> ...
>
> > cnxOMC = mysql.connector.connect(user="root",
>
> > password='PK17LP12r',
>
> > host='localhost',
>
> > database='TESTERS')
>
>
>
> You pass the hardcoded parameters as keyword arguments, unlike in the
>
> version that doesn't work. Maybe that is the difference. Try this:
>
>
>
> cnxOMC = mysql.connector.connect(user=user,
>
> password=password,
>
> host='localhost',
>
> database=database)
>
>
>
> It only looks funny. In "user=user" the first "user" is a parameter
>
> name, the other is the variable in your code.
>
>
>
> Try help(mysql.connector.connect) at the interactive prompt, or
>
> otherwise check the documentation.
Thanks a lot man, it worked flawlessly.
More information about the Python-list
mailing list