MySQL from python - dropping a database IF EXISTS

Discussion in 'Python' started by Ben, Dec 4, 2006.

  1. Ben

    Ben Guest

    Can someone explain why this might be happening:

    parser_beta.py:129: Warning: Can't drop database 'foobar'; database
    doesn't exist
    self.cursor.execute("DROP DATABASE IF EXISTS "+name)

    But the whole point about the "IF EXISTS" bit is (I thought) that it
    will only drop it if it exists, if it doesn't do nothing and don't
    throw an error.

    I'm using MySQL 5.024 and python 2.4.3

    It still works, but the unneccesary error is annoying :) Any ideas?

    Cheers,

    Ben
     
    Ben, Dec 4, 2006
    #1
    1. Advertising

  2. Ben

    Ben Guest

    Re: MySQL from python - dropping a database IF EXISTS

    Ah well - I turned off warnings as a solution. Its a bit f a bodge, but
    it works :)


    Ben wrote:

    > Can someone explain why this might be happening:
    >
    > parser_beta.py:129: Warning: Can't drop database 'foobar'; database
    > doesn't exist
    > self.cursor.execute("DROP DATABASE IF EXISTS "+name)
    >
    > But the whole point about the "IF EXISTS" bit is (I thought) that it
    > will only drop it if it exists, if it doesn't do nothing and don't
    > throw an error.
    >
    > I'm using MySQL 5.024 and python 2.4.3
    >
    > It still works, but the unneccesary error is annoying :) Any ideas?
    >
    > Cheers,
    >
    > Ben
     
    Ben, Dec 4, 2006
    #2
    1. Advertising

  3. Fredrik Lundh, Dec 5, 2006
    #3
    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. Totan
    Replies:
    0
    Views:
    1,034
    Totan
    Apr 17, 2006
  2. David Härdeman

    Dropping privileges in python daemon

    David Härdeman, Aug 18, 2008, in forum: Python
    Replies:
    1
    Views:
    407
    Matthias Bläsing
    Aug 18, 2008
  3. Replies:
    3
    Views:
    284
    Aaron Brady
    Nov 7, 2008
  4. Ulf Meinhardt
    Replies:
    8
    Views:
    6,228
  5. julian
    Replies:
    8
    Views:
    472
    Avatar
    Apr 6, 2006
Loading...

Share This Page