0

while i am trying to connect with python MySQLdb, i get an 'Invalid Arguments' error.

import MySQLdb
conn = MySQLdb.connect (host = "localhost",user = "root",passwd = "",db = "test")

what is the reason for getting such a error?.

But, the following code with _mysql works fine.

db=_mysql.connect("localhost","root","","test")
asked Jan 24, 2011 at 7:19
1
  • Just a note - "localhost" is the default host for MySQLdb, so you don't need to specify it. Commented Jan 24, 2011 at 7:24

2 Answers 2

2
import MySQLdb.cursors
DATABASE= MySQLdb.connect(host='localhost', user='username', passwd='password', db='databasename', cursorclass=MySQLdb.cursors.DictCursor)

Hope it helps.

answered Jan 24, 2011 at 8:46
Sign up to request clarification or add additional context in comments.

Comments

0

Shouldn't that be

conn = MySQLdb.connect ("localhost","root","","test")

?

(random reference: http://www.tutorialspoint.com/python/python_database_access.htm )

answered Jan 24, 2011 at 7:54

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.