need help with MySQLdb

Discussion in 'Python' started by nephish@xit.net, Jun 30, 2005.

  1. Guest

    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
     
    , Jun 30, 2005
    #1
    1. Advertising

  2. 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
     
    Wolfram Kraus, Jun 30, 2005
    #2
    1. Advertising

  3. On 29 Jun 2005 21:56:49 -0700, 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.

    --
    > ============================================================== <
    > | Wulfraed Dennis Lee Bieber KD6MOG <
    > | Bestiaria Support Staff <
    > ============================================================== <
    > Home Page: <http://www.dm.net/~wulfraed/> <
    > Overflow Page: <http://wlfraed.home.netcom.com/> <
     
    Dennis Lee Bieber, Jun 30, 2005
    #3
  4. On Thu, 30 Jun 2005 06:47:18 GMT, Dennis Lee Bieber
    <> declaimed the following in comp.lang.python:

    > On 29 Jun 2005 21:56:49 -0700, 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}

    --
    > ============================================================== <
    > | Wulfraed Dennis Lee Bieber KD6MOG <
    > | Bestiaria Support Staff <
    > ============================================================== <
    > Home Page: <http://www.dm.net/~wulfraed/> <
    > Overflow Page: <http://wlfraed.home.netcom.com/> <
     
    Dennis Lee Bieber, Jun 30, 2005
    #4
  5. 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
     
    Wolfram Kraus, Jun 30, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kiran B.
    Replies:
    0
    Views:
    306
    Kiran B.
    Nov 5, 2003
  2. Thiago
    Replies:
    1
    Views:
    487
    Jarek Zgoda
    Jul 4, 2004
  3. ws Wang
    Replies:
    2
    Views:
    492
    ws Wang
    Nov 30, 2004
  4. rodmc
    Replies:
    10
    Views:
    526
    Simon Forman
    Jun 23, 2006
  5. Romaric DEFAUX
    Replies:
    0
    Views:
    272
    Romaric DEFAUX
    Jan 20, 2011
Loading...

Share This Page