Jump to content


Photo

python & mysql


  • Please log in to reply
No replies to this topic

#1 labete

labete

    Newbie

  • Member
  • Pip
  • 1 posts
  • Main OS: Windows XP

Posted 18 June 2010 - 12:16 PM

Sorry, I found out by myself. I leave the topic in case it could help someone

Hi!

I am trying to install a local mysql server to use with python. Fail so far:

the mini servers 11 and 12 seem to work fine: I can browse the user table in mysql db.
I have python 2.6 installed alongside mysql-python1.2.3

But I cannot connect to the mini server thru python:

import MySQLdb
c=MySQLdb.connect(host="127.0.0.1:3312",user="root",passwd="test",db="mysql")
or
c=MySQLdb.connect("localhost:3311","root","test","mysql")
or
any combination of the above outputs ST like:
OperationalError: (2005, "Unknown MySQL server host '127.0.0.1:3312' (11001)")

So, do I do anything wrong? Any advice?
Thanks

One has to type instead:
c=MySQLdb.connect(host="127.0.0.1", port=3312,user="root",passwd="test",db="mysql")
or
c=MySQLdb.connect("localhost","root","test","mysql", 3312)

HTH n sorry if i botherd you.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users