Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > need help with MySQLdb

Reply
Thread Tools

need help with MySQLdb

 
 
nephish@xit.net
Guest
Posts: n/a
 
      06-30-2005
Hey there all,
i have a question about how to point my python install to my sql
database.

when i enter this: db = MySQLdb.connect(user="user", passwd="pass",
db="myDB")

i get this:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in -toplevel-
db = MySQLdb.connect(user="user", passwd="pass", db="MyDB")
File "/usr/lib/python2.4/site-packages/MySQLdb/__init__.py", line 66,
in Connect
return Connection(*args, **kwargs)
File "/usr/lib/python2.4/site-packages/MySQLdb/connections.py", line
134, in __init__
super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (1049, "Unknown database 'MyDB'")

i am using the all in one package from lampp (now xampp) and i have
tested a couple of python scripts from the cgi, but.... nothing that
connects to the database.

any ideas?

thanks

 
Reply With Quote
 
 
 
 
Wolfram Kraus
Guest
Posts: n/a
 
      06-30-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Hey there all,
> i have a question about how to point my python install to my sql
> database.
>
> when i enter this: db = MySQLdb.connect(user="user", passwd="pass",
> db="myDB")
>
> i get this:
> Traceback (most recent call last):
> File "<pyshell#1>", line 1, in -toplevel-
> db = MySQLdb.connect(user="user", passwd="pass", db="MyDB")
> File "/usr/lib/python2.4/site-packages/MySQLdb/__init__.py", line 66,
> in Connect
> return Connection(*args, **kwargs)
> File "/usr/lib/python2.4/site-packages/MySQLdb/connections.py", line
> 134, in __init__
> super(Connection, self).__init__(*args, **kwargs2)
> OperationalError: (1049, "Unknown database 'MyDB'")
>
> i am using the all in one package from lampp (now xampp) and i have
> tested a couple of python scripts from the cgi, but.... nothing that
> connects to the database.
>
> any ideas?
>
> thanks
>

Try the following from the shell (NOT the python shell):
mysql -u user -p
[Enter passwd]
mysql> show databases;

If MyDB isn't in the list either something went wrong with the xampp
installation or the database for xampp got a different name. (I am no
xampp expert, so I can't help you any further)

HTH,
Wolfram
 
Reply With Quote
 
 
 
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      06-30-2005
On 29 Jun 2005 21:56:49 -0700, (E-Mail Removed) declaimed the following
in comp.lang.python:


> any ideas?
>

Step 1: show us what the interactive command line tool "mysql"
does with...


mysql user -p
pass
use MyDB;

IOW, verify you can connect to the database using the MySQL
tools first, then figure out what is different with the MySQLdb call.

--
> ================================================== ============ <
> (E-Mail Removed) | Wulfraed Dennis Lee Bieber KD6MOG <
> (E-Mail Removed) | Bestiaria Support Staff <
> ================================================== ============ <
> Home Page: <http://www.dm.net/~wulfraed/> <
> Overflow Page: <http://wlfraed.home.netcom.com/> <

 
Reply With Quote
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      06-30-2005
On Thu, 30 Jun 2005 06:47:18 GMT, Dennis Lee Bieber
<(E-Mail Removed)> declaimed the following in comp.lang.python:

> On 29 Jun 2005 21:56:49 -0700, (E-Mail Removed) declaimed the following
> in comp.lang.python:
>
>
> > any ideas?
> >

> Step 1: show us what the interactive command line tool "mysql"
> does with...
>
>
> mysql user -p
> pass
> use MyDB;
>
> IOW, verify you can connect to the database using the MySQL
> tools first, then figure out what is different with the MySQLdb call.


{okay, slight error in the command line string -- I haven't ported MySQL
from the old W98 machine to the WinXP machine yet}

--
> ================================================== ============ <
> (E-Mail Removed) | Wulfraed Dennis Lee Bieber KD6MOG <
> (E-Mail Removed) | Bestiaria Support Staff <
> ================================================== ============ <
> Home Page: <http://www.dm.net/~wulfraed/> <
> Overflow Page: <http://wlfraed.home.netcom.com/> <

 
Reply With Quote
 
Wolfram Kraus
Guest
Posts: n/a
 
      06-30-2005
nephish wrote:
[...]

>> Try the following from the shell (NOT the python shell):
>> mysql -u user -p
>> [Enter passwd]
>> mysql> show databases;
>>
>> If MyDB isn't in the list either something went wrong with the xampp
>> installation or the database for xampp got a different name. (I am no
>> xampp expert, so I can't help you any further)
>>
>> HTH,
>> Wolfram
>>
>>

> after i entered the password it told me it cannot connect to mysql through
> socket /tmp/mysql.sock
>
> hmmmm.
> hope this helps


Please keep the discussion on the list

Try
mysql -u user -p -h 127.0.0.1

HTH,
Wolfram
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need advices for mysqldb connection best practice Romaric DEFAUX Python 0 01-20-2011 09:04 AM
Help req: Problems with MySQLdb rodmc Python 10 06-23-2006 04:05 PM
MySQLdb problem with mod_python, please help ws Wang Python 2 11-30-2004 08:40 PM
Install MySQLdb for Python win32 need Visual Studio 6 Thiago Python 1 07-04-2004 07:37 PM
Importing MySQLdb module causes malformed header error.. pls help!!! Kiran B. Python 0 11-05-2003 01:52 PM



Advertisments